From 63be2308d373e75110a76d985166388b8d919949 Mon Sep 17 00:00:00 2001 From: jelveh Date: Fri, 1 May 2026 20:24:09 -0700 Subject: [PATCH] Show upgrade dialog on storage limit errors --- .../src/modules/FileSystem/operations/upload.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/puter-js/src/modules/FileSystem/operations/upload.js b/src/puter-js/src/modules/FileSystem/operations/upload.js index 2c3281ffe..bd402e5b8 100644 --- a/src/puter-js/src/modules/FileSystem/operations/upload.js +++ b/src/puter-js/src/modules/FileSystem/operations/upload.js @@ -1,6 +1,7 @@ import path from '../../../lib/path.js'; import * as utils from '../../../lib/utils.js'; import getAbsolutePathForApp from '../utils/getAbsolutePathForApp.js'; +import { showUsageLimitDialog } from '../../../modules/UsageLimitDialog.js'; /* eslint-disable */ const MAX_THUMBNAIL_BYTES = 2 * 1024 * 1024; @@ -358,6 +359,19 @@ const upload = async function (items, dirPath, options = {}) { } const error = (e) => { + // Check for storage limit errors and show upgrade dialog + const isStorageError = + e?.code === 'NOT_ENOUGH_SPACE' || + e?.status === 413 || + e?.code === 'storage_limit_reached'; + if ( isStorageError ) { + if ( puter.env === 'web' ) { + showUsageLimitDialog('Not enough storage space available.
Please upgrade to continue.'); + } else if ( puter.env === 'app' ) { + puter.ui.requestUpgrade(); + } + } + // if error callback is provided, call it if ( options.error && typeof options.error === 'function' ) {