Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat: add storage pay-as-you-go stubs and locale keys (#13501)

YuTengjing8dee729f9f24
diff --git a/locales/en-US/error.json b/locales/en-US/error.json
index 973430efffe..f09c39e2f7a 100644
--- a/locales/en-US/error.json
+++ b/locales/en-US/error.json
@@ -129,6 +129,14 @@
"upload.desc": "Details: {{detail}}",
"upload.fileOnlySupportInServerMode": "The current deployment mode does not support uploading non-image files. To upload files in {{ext}} format, please switch to server database deployment or use the {{cloud}} service.",
"upload.networkError": "Please check your network connection and ensure that the file storage service's cross-origin configuration is correct.",
+ "upload.storageBlock.monthlyCapReached": "Your monthly storage spending cap has been reached.",
+ "upload.storageBlock.noPaymentMethod": "Please add a payment method to continue uploading.",
+ "upload.storageBlock.overageNotEnabled": "Your storage is full. Enable pay-as-you-go billing to continue uploading.",
+ "upload.storageBlock.subscriptionPastDue": "Your subscription payment has failed. Please update your payment method.",
+ "upload.storageBlock.subscriptionUnpaid": "Your subscription has been suspended. Please resolve the outstanding payment.",
+ "upload.storageBlock.upgradeRequired": "Your file storage has reached the plan limit. Please upgrade your plan or delete unused files.",
+ "upload.storageBlock.viewPlans": "View plans",
+ "upload.storageBlock.viewUsage": "View storage usage",
"upload.storageLimitExceeded": "Your file storage has reached the plan limit. Please upgrade your plan or delete unused files to free up space.",
"upload.title": "File upload failed. Please check your network connection or try again later",
"upload.unknownError": "Error reason: {{reason}}",
diff --git a/locales/en-US/notification.json b/locales/en-US/notification.json
index d4f85ce5088..c0324b4a0c6 100644
--- a/locales/en-US/notification.json
+++ b/locales/en-US/notification.json
@@ -13,6 +13,8 @@
"inbox.filterUnread": "Show unread only",
"inbox.markAllRead": "Mark all as read",
"inbox.title": "Notifications",
+ "storage_overage_cap_reached": "Your storage pay-as-you-go monthly cap of ${{monthlyCap}} has been reached. Estimated charges this cycle are ${{estimatedCycleCharge}}. New uploads beyond your included storage will be blocked until the next billing cycle or until you increase the cap.",
+ "storage_overage_cap_reached_title": "Storage pay-as-you-go cap reached",
"video_generation_completed": "Your video \"{{prompt}}\" is ready.",
"video_generation_completed_title": "Video generation completed"
}
diff --git a/locales/en-US/setting.json b/locales/en-US/setting.json
index d761ed60321..f5420aa5c0a 100644
--- a/locales/en-US/setting.json
+++ b/locales/en-US/setting.json
@@ -494,6 +494,7 @@
"myAgents.status.published": "Published",
"myAgents.status.unpublished": "Unpublished",
"myAgents.title": "My Published Agents",
+ "notification.category.billing.title": "Billing",
"notification.category.generation.title": "Generation",
"notification.category.schedule.title": "Scheduled tasks",
"notification.email.desc": "Receive email notifications when important events occur",
@@ -503,6 +504,7 @@
"notification.inbox.title": "Inbox Notifications",
"notification.item.agent_cron_job_failed": "Scheduled task failed",
"notification.item.image_generation_completed": "Image generation completed",
+ "notification.item.storage_overage_cap_reached": "Storage pay-as-you-go cap reached",
"notification.item.video_generation_completed": "Video generation completed",
"notification.push.desc": "Send push notifications to your mobile devices (LobeHub mobile app required)",
"notification.push.title": "Mobile Push Notifications",
@@ -848,6 +850,42 @@
"storage.embeddings.used": "Vector Storage",
"storage.title": "Data Storage",
"storage.used": "Storage Usage",
+ "storageOverage.addPaymentMethod": "Add payment method",
+ "storageOverage.capUpdateFailed": "Failed to update monthly cap.",
+ "storageOverage.capUpdated": "Monthly cap updated.",
+ "storageOverage.capped": "Monthly spending cap reached. Overage uploads are paused.",
+ "storageOverage.consent.billedTogether": "Billed together with your subscription",
+ "storageOverage.consent.canDisable": "Can be disabled anytime",
+ "storageOverage.consent.description": "Storage exceeding your plan quota will be charged:",
+ "storageOverage.consent.enable": "Agree and enable",
+ "storageOverage.consent.onlyOverage": "Only overage is charged",
+ "storageOverage.consent.rate": "About {{limitedMonthlyRate}}/GB/month for a limited time (regular {{regularMonthlyRate}}).",
+ "storageOverage.consent.title": "Enable Storage Pay-as-you-go",
+ "storageOverage.currentPlanLocked.desc": "Your current plan does not support storage pay-as-you-go. After it ends, subscribe to a plan to enable it.",
+ "storageOverage.desc": "Subscription plans can enable metered billing for storage beyond the included quota.",
+ "storageOverage.disableConfirm.blockUploads": "If your storage is still above the included quota, new uploads will be blocked.",
+ "storageOverage.disableConfirm.canEnableAgain": "You can enable storage pay-as-you-go again later.",
+ "storageOverage.disableConfirm.confirm": "Disable",
+ "storageOverage.disableConfirm.description": "After disabling, storage overage will no longer be billed.",
+ "storageOverage.disableConfirm.existingCharges": "Charges already incurred in this billing cycle will still be included on your subscription invoice.",
+ "storageOverage.disableConfirm.title": "Disable storage pay-as-you-go?",
+ "storageOverage.disableFailed": "Failed to disable storage pay-as-you-go.",
+ "storageOverage.disabled": "Storage pay-as-you-go disabled.",
+ "storageOverage.enableFailed": "Failed to enable storage pay-as-you-go.",
+ "storageOverage.enabled": "Storage pay-as-you-go enabled.",
+ "storageOverage.monthlyCap": "Monthly Spending Cap",
+ "storageOverage.monthlyCapDesc": "Stop overage uploads after this cap is reached in the current billing cycle. Leave empty for no cap.",
+ "storageOverage.noPaymentMethod": "Please add a payment method to enable storage pay-as-you-go.",
+ "storageOverage.rate": "About {{limitedMonthlyRate}}/GB/month for a limited time (regular {{regularMonthlyRate}}).",
+ "storageOverage.subscriptionRequired.action": "View plans",
+ "storageOverage.subscriptionRequired.desc": "Subscribe to a plan to enable storage pay-as-you-go for overage usage.",
+ "storageOverage.title": "File Storage Pay-as-you-go",
+ "storageOverage.toggle": "Enable overage billing",
+ "storageOverage.unlimited": "Unlimited",
+ "storageOverage.usage.current": "Usage",
+ "storageOverage.usage.estimatedCharge": "Est. Cycle Charge",
+ "storageOverage.usage.incurredCharge": "Incurred This Cycle",
+ "storageOverage.usage.overage": "Overage",
"submitAgentModal.button": "Submit Agent",
"submitAgentModal.identifier": "Agent Identifier",
"submitAgentModal.metaMiss": "Please complete the agent information before submitting. It should include name, description, and tags",
diff --git a/locales/en-US/subscription.json b/locales/en-US/subscription.json
index 5179c22ff47..4d3f3faf0d9 100644
--- a/locales/en-US/subscription.json
+++ b/locales/en-US/subscription.json
@@ -257,6 +257,7 @@
"plans.features.plugins": "Exclusive Premium Plugins",
"plans.features.showAll": "View All Features",
"plans.features.title": "Premium Features",
+ "plans.fileStorage.storagePayAsYouGo": "Storage overages support pay-as-you-go billing",
"plans.fileStorage.title": "File Storage",
"plans.fileStorage.tooltip": "File storage for storing files, images, and other data",
"plans.free": "Free",
@@ -283,7 +284,7 @@
"plans.navs.yearly": "Yearly",
"plans.payonce.cancel": "Cancel",
"plans.payonce.ok": "Confirm Selection",
- "plans.payonce.popconfirm": "After one-time payment, you can upgrade anytime but downgrade requires waiting for expiration. Please confirm your selection.",
+ "plans.payonce.popconfirm": "After one-time payment, you can upgrade anytime, but downgrade requires waiting for expiration. Storage pay-as-you-go is not supported. Please confirm your selection.",
"plans.payonce.tooltip": "One-time payment only supports upgrading to a higher tier or longer duration",
"plans.payonce.upgradeOk": "Confirm Upgrade",
"plans.payonce.upgradePopconfirm": "Remaining value from your current plan will be applied as a discount to the new plan.",
@@ -394,10 +395,11 @@
"referral.table.status.suspected": "Suspected Anomaly",
"referral.table.title": "Referral History",
"sessionCard.title": "Ready to leave the free plan? Upgrade to enjoy premium features.",
- "summary.desc": "This amount only includes subscription service expenses.",
+ "summary.desc": "This amount includes your subscription fee and any storage overage charges for this billing period.",
"summary.dueBy": "Due on {{date}}",
"summary.nextPayment": "Your Next Payment",
"summary.paymentInformation": "Billing Information",
+ "summary.storageSettings": "Storage pay-as-you-go",
"summary.title": "Billing Summary",
"summary.usageThisMonth": "View your usage this month.",
"summary.viewBillingHistory": "View Payment History",
diff --git a/locales/zh-CN/error.json b/locales/zh-CN/error.json
index 3c9b0469fa4..133325060e8 100644
--- a/locales/zh-CN/error.json
+++ b/locales/zh-CN/error.json
@@ -154,6 +154,15 @@
"upload.desc": "详情:{{detail}}",
"upload.fileOnlySupportInServerMode": "当前部署模式不支持上传非图片文件。若需上传 {{ext}},请切换到服务端数据库部署或使用 {{cloud}}",
"upload.networkError": "网络异常或跨域配置不正确。请检查文件存储服务的 CORS 设置后重试",
+ "upload.storageBlock.billingUnavailable": "当前订阅账单状态无法确认,请稍后重试或更新账单信息。",
+ "upload.storageBlock.monthlyCapReached": "已达到月度存储消费上限。",
+ "upload.storageBlock.noPaymentMethod": "请添加支付方式后继续上传。",
+ "upload.storageBlock.overageNotEnabled": "存储空间已满。启用按量付费后可继续上传。",
+ "upload.storageBlock.subscriptionPastDue": "订阅扣款失败。请更新支付方式后继续上传。",
+ "upload.storageBlock.subscriptionUnpaid": "订阅已暂停。请处理未支付账单后继续上传。",
+ "upload.storageBlock.upgradeRequired": "文件存储空间已达到当前套餐上限,请升级套餐或删除不需要的文件。",
+ "upload.storageBlock.viewPlans": "查看套餐",
+ "upload.storageBlock.viewUsage": "查看存储用量",
"upload.storageLimitExceeded": "文件存储空间已达到当前套餐上限,请升级套餐或删除不需要的文件以释放空间。",
"upload.title": "上传未能完成",
"upload.unknownError": "原因:{{reason}}",
diff --git a/locales/zh-CN/notification.json b/locales/zh-CN/notification.json
index a639b303cd5..d8cd3555744 100644
--- a/locales/zh-CN/notification.json
+++ b/locales/zh-CN/notification.json
@@ -13,6 +13,8 @@
"inbox.filterUnread": "仅显示未读",
"inbox.markAllRead": "全部标为已读",
"inbox.title": "通知",
+ "storage_overage_cap_reached": "您的存储按量付费月度上限 ${{monthlyCap}} 已触达。本周期预计费用为 ${{estimatedCycleCharge}}。超出套餐存储额度的新上传会被阻止,直到下个账单周期或您提高上限。",
+ "storage_overage_cap_reached_title": "存储按量付费上限已触达",
"video_generation_completed": "视频「{{prompt}}」已生成。",
"video_generation_completed_title": "视频生成完成"
}
diff --git a/locales/zh-CN/setting.json b/locales/zh-CN/setting.json
index eb21b27c1c9..b7de9f81261 100644
--- a/locales/zh-CN/setting.json
+++ b/locales/zh-CN/setting.json
@@ -494,6 +494,7 @@
"myAgents.status.published": "已上架",
"myAgents.status.unpublished": "未上架",
"myAgents.title": "我发布的助理",
+ "notification.category.billing.title": "账单",
"notification.category.generation.title": "生成",
"notification.category.schedule.title": "定时任务",
"notification.email.desc": "当重要事件发生时接收邮件通知",
@@ -503,6 +504,7 @@
"notification.inbox.title": "站内通知",
"notification.item.agent_cron_job_failed": "计划任务失败",
"notification.item.image_generation_completed": "图片生成完成",
+ "notification.item.storage_overage_cap_reached": "存储按量付费上限已触达",
"notification.item.video_generation_completed": "视频生成完成",
"notification.push.desc": "向您的移动设备发送推送通知(需要安装 LobeHub 移动应用)",
"notification.push.title": "移动推送通知",
@@ -848,6 +850,43 @@
"storage.embeddings.used": "向量存储",
"storage.title": "数据存储",
"storage.used": "存储用量",
+ "storageOverage.addPaymentMethod": "添加支付方式",
+ "storageOverage.capUpdateFailed": "月度上限更新失败。",
+ "storageOverage.capUpdated": "月度上限已更新。",
+ "storageOverage.capped": "已达到月度消费上限,超额上传已暂停。",
+ "storageOverage.consent.billedMonthlyForYearly": "存储超额费用按月结算,不等到年费续订时结算",
+ "storageOverage.consent.billedTogether": "将与订阅账单一起结算",
+ "storageOverage.consent.canDisable": "可随时关闭",
+ "storageOverage.consent.description": "超出套餐额度的存储将按以下标准计费:",
+ "storageOverage.consent.enable": "同意并启用",
+ "storageOverage.consent.onlyOverage": "仅对超出额度的部分计费",
+ "storageOverage.consent.rate": "限时约 {{limitedMonthlyRate}}/GB/月(原价 {{regularMonthlyRate}})。",
+ "storageOverage.consent.title": "启用存储按量付费",
+ "storageOverage.currentPlanLocked.desc": "当前计划暂不支持存储按量付费。计划结束后,订阅套餐即可开启。",
+ "storageOverage.desc": "订阅套餐可为超出套餐额度的存储启用按量计费。",
+ "storageOverage.disableConfirm.blockUploads": "如果当前文件存储仍超出套餐额度,新上传会被拦截。",
+ "storageOverage.disableConfirm.canEnableAgain": "之后可随时重新开启文件存储按量付费。",
+ "storageOverage.disableConfirm.confirm": "确认关闭",
+ "storageOverage.disableConfirm.description": "关闭后,超出套餐额度的文件存储将不再继续按量计费。",
+ "storageOverage.disableConfirm.existingCharges": "本账期已产生的费用仍会随订阅账单结算。",
+ "storageOverage.disableConfirm.title": "关闭文件存储按量付费?",
+ "storageOverage.disableFailed": "存储按量付费关闭失败。",
+ "storageOverage.disabled": "存储按量付费已关闭。",
+ "storageOverage.enableFailed": "存储按量付费启用失败。",
+ "storageOverage.enabled": "存储按量付费已启用。",
+ "storageOverage.monthlyCap": "月度消费上限",
+ "storageOverage.monthlyCapDesc": "达到该上限后,本账期内会暂停超额上传。留空表示不设置上限。",
+ "storageOverage.noPaymentMethod": "请先添加支付方式,再启用存储按量付费。",
+ "storageOverage.rate": "限时约 {{limitedMonthlyRate}}/GB/月(原价 {{regularMonthlyRate}})。",
+ "storageOverage.subscriptionRequired.action": "查看套餐",
+ "storageOverage.subscriptionRequired.desc": "订阅套餐后,可为超出额度的文件存储启用按量付费。",
+ "storageOverage.title": "文件存储按量付费",
+ "storageOverage.toggle": "启用超额存储计费",
+ "storageOverage.unlimited": "不设上限",
+ "storageOverage.usage.current": "用量",
+ "storageOverage.usage.estimatedCharge": "预计本账期费用",
+ "storageOverage.usage.incurredCharge": "本账期已产生费用",
+ "storageOverage.usage.overage": "超额",
"submitAgentModal.button": "提交助理",
"submitAgentModal.identifier": "助理标识符(identifier)",
"submitAgentModal.metaMiss": "请补全助理信息后提交,需要包含名称、描述和标签",
diff --git a/locales/zh-CN/subscription.json b/locales/zh-CN/subscription.json
index ef843261d68..68d52a8adb3 100644
--- a/locales/zh-CN/subscription.json
+++ b/locales/zh-CN/subscription.json
@@ -257,6 +257,7 @@
"plans.features.plugins": "专属高级插件",
"plans.features.showAll": "查看全部功能",
"plans.features.title": "高级功能",
+ "plans.fileStorage.storagePayAsYouGo": "超出文件存储额度后支持按量付费",
"plans.fileStorage.title": "文件存储",
"plans.fileStorage.tooltip": "用于存储文件、图片等数据的空间",
"plans.free": "免费",
@@ -283,7 +284,7 @@
"plans.navs.yearly": "按年",
"plans.payonce.cancel": "取消",
"plans.payonce.ok": "确认选择",
- "plans.payonce.popconfirm": "一次性付款后可随时升级,降级需等到期。请确认您的选择。",
+ "plans.payonce.popconfirm": "一次性付款后可随时升级,降级需等到期,且不支持文件存储按量付费。请确认您的选择。",
"plans.payonce.tooltip": "一次性付款仅支持升级到更高档位或更长时长",
"plans.payonce.upgradeOk": "确认升级",
"plans.payonce.upgradePopconfirm": "当前计划的剩余价值将作为折扣应用于新计划。",
@@ -396,10 +397,14 @@
"referral.table.status.suspected": "疑似异常",
"referral.table.title": "推荐记录",
"sessionCard.title": "准备离开免费计划?升级以享受高级功能。",
- "summary.desc": "此金额仅包含订阅服务费用。",
+ "summary.annualRenewal": "年费套餐续费:{{amount}},{{date}}",
+ "summary.desc": "此金额包含订阅费用和本期超额存储费用。",
"summary.dueBy": "应付款日期:{{date}}",
+ "summary.nextMonthlyPayment": "您的下月付款",
"summary.nextPayment": "您的下次付款",
"summary.paymentInformation": "账单信息",
+ "summary.storageMonthlyDesc": "此金额为当前月度账期内的存储超额费用。",
+ "summary.storageSettings": "存储按量付费",
"summary.title": "账单摘要",
"summary.usageThisMonth": "查看本月使用情况。",
"summary.viewBillingHistory": "查看付款记录",
diff --git a/src/business/client/features/StoragePayAsYouGo/index.tsx b/src/business/client/features/StoragePayAsYouGo/index.tsx
new file mode 100644
index 00000000000..1e85b0264eb
--- /dev/null
+++ b/src/business/client/features/StoragePayAsYouGo/index.tsx
@@ -0,0 +1,3 @@
+export default function StoragePayAsYouGo() {
+ return null;
+}
diff --git a/src/business/client/handleFileUploadError.ts b/src/business/client/handleFileUploadError.ts
new file mode 100644
index 00000000000..f8659fe1479
--- /dev/null
+++ b/src/business/client/handleFileUploadError.ts
@@ -0,0 +1,6 @@
+export interface HandleFileUploadErrorOptions {
+ onUploadBlocked?: () => void;
+}
+
+export const handleFileUploadError = (_error: unknown, _options?: HandleFileUploadErrorOptions) =>
+ false;
diff --git a/src/business/server/lambda-routers/storageOverage.ts b/src/business/server/lambda-routers/storageOverage.ts
new file mode 100644
index 00000000000..53792dd08d4
--- /dev/null
+++ b/src/business/server/lambda-routers/storageOverage.ts
@@ -0,0 +1,3 @@
+import { router } from '@/libs/trpc/lambda';
+
+export const storageOverageRouter = router({});
diff --git a/src/config/featureFlags/schema.test.ts b/src/config/featureFlags/schema.test.ts
index 3d70701e74e..931d333144f 100644
--- a/src/config/featureFlags/schema.test.ts
+++ b/src/config/featureFlags/schema.test.ts
@@ -107,6 +107,12 @@ describe('mapFeatureFlagsEnvToState', () => {
expect(mappedState.enableAuthCaptcha).toBe(true);
});
+ it('should enable storage overage by default', () => {
+ const mappedState = mapFeatureFlagsEnvToState(DEFAULT_FEATURE_FLAGS);
+
+ expect(mappedState.enableStorageOverage).toBe(true);
+ });
+
it('should correctly map boolean feature flags to state', () => {
const config = {
provider_settings: true,
@@ -126,6 +132,7 @@ describe('mapFeatureFlagsEnvToState', () => {
changelog: false,
api_key_manage: false,
cloud_promotion: true,
+ storage_overage: false,
commercial_hide_github: false,
commercial_hide_docs: true,
};
@@ -147,6 +154,7 @@ describe('mapFeatureFlagsEnvToState', () => {
enableAgentSelfIteration: true,
enableAgentOnboarding: true,
enableAuthCaptcha: true,
+ enableStorageOverage: false,
showMarket: true,
enableSTT: true,
showCloudPromotion: true,
@@ -162,6 +170,7 @@ describe('mapFeatureFlagsEnvToState', () => {
agent_self_iteration: ['user-123'],
agent_onboarding: ['user-123'],
auth_captcha: ['user-123'],
+ storage_overage: ['user-123'],
create_session: ['user-789'],
dalle: true,
knowledge_base: ['user-123'],
@@ -174,6 +183,7 @@ describe('mapFeatureFlagsEnvToState', () => {
expect(mappedState.enableAgentSelfIteration).toBe(true); // user-123 is in allowlist
expect(mappedState.enableAgentOnboarding).toBe(true); // user-123 is in allowlist
expect(mappedState.enableAuthCaptcha).toBe(true); // user-123 is in allowlist
+ expect(mappedState.enableStorageOverage).toBe(true); // user-123 is in allowlist
expect(mappedState.enableKnowledgeBase).toBe(true); // user-123 is in allowlist
});
diff --git a/src/config/featureFlags/schema.ts b/src/config/featureFlags/schema.ts
index 021ea03f12b..af1bfa8622c 100644
--- a/src/config/featureFlags/schema.ts
+++ b/src/config/featureFlags/schema.ts
@@ -35,6 +35,7 @@ export const FeatureFlagsSchema = z.object({
// Cloud feature flag. Keep here until cloud owns a separate runtime flag domain.
auth_captcha: FeatureFlagValue.optional(),
cloud_promotion: FeatureFlagValue.optional(),
+ storage_overage: FeatureFlagValue.optional(),
// the flags below can only be used with commercial license
// if you want to use it in the commercial usage
@@ -84,6 +85,7 @@ export const DEFAULT_FEATURE_FLAGS: IFeatureFlags = {
agent_onboarding: isDev,
auth_captcha: true,
cloud_promotion: false,
+ storage_overage: true,
market: true,
speech_to_text: true,
@@ -117,6 +119,7 @@ export const mapFeatureFlagsEnvToState = (config: IFeatureFlags, userId?: string
enableAgentSelfIteration: evaluateFeatureFlag(config.agent_self_iteration, userId),
enableAgentOnboarding: evaluateFeatureFlag(config.agent_onboarding, userId),
enableAuthCaptcha: evaluateFeatureFlag(config.auth_captcha, userId),
+ enableStorageOverage: evaluateFeatureFlag(config.storage_overage, userId),
showCloudPromotion: evaluateFeatureFlag(config.cloud_promotion, userId),
diff --git a/src/locales/default/error.ts b/src/locales/default/error.ts
index 48507e3dd93..3f48ca0c7f1 100644
--- a/src/locales/default/error.ts
+++ b/src/locales/default/error.ts
@@ -204,6 +204,20 @@ export default {
'The current deployment mode does not support uploading non-image files. To upload files in {{ext}} format, please switch to server database deployment or use the {{cloud}} service.',
'upload.networkError':
"Please check your network connection and ensure that the file storage service's cross-origin configuration is correct.",
+ 'upload.storageBlock.billingUnavailable':
+ 'Your subscription billing status cannot be verified. Please try again later or update your billing details.',
+ 'upload.storageBlock.monthlyCapReached': 'Your monthly storage spending cap has been reached.',
+ 'upload.storageBlock.noPaymentMethod': 'Please add a payment method to continue uploading.',
+ 'upload.storageBlock.viewUsage': 'View storage usage',
+ 'upload.storageBlock.overageNotEnabled':
+ 'Your storage is full. Enable pay-as-you-go billing to continue uploading.',
+ 'upload.storageBlock.subscriptionPastDue':
+ 'Your subscription payment has failed. Please update your payment method.',
+ 'upload.storageBlock.subscriptionUnpaid':
+ 'Your subscription has been suspended. Please resolve the outstanding payment.',
+ 'upload.storageBlock.upgradeRequired':
+ 'Your file storage has reached the plan limit. Please upgrade your plan or delete unused files.',
+ 'upload.storageBlock.viewPlans': 'View plans',
'upload.storageLimitExceeded':
'Your file storage has reached the plan limit. Please upgrade your plan or delete unused files to free up space.',
'upload.title': 'File upload failed. Please check your network connection or try again later',
diff --git a/src/locales/default/notification.ts b/src/locales/default/notification.ts
index 3e335d1b7f7..303fdb1497e 100644
--- a/src/locales/default/notification.ts
+++ b/src/locales/default/notification.ts
@@ -15,6 +15,9 @@ export default {
'inbox.filterUnread': 'Show unread only',
'inbox.markAllRead': 'Mark all as read',
'inbox.title': 'Notifications',
+ 'storage_overage_cap_reached':
+ 'Your storage pay-as-you-go monthly cap of ${{monthlyCap}} has been reached. Estimated charges this cycle are ${{estimatedCycleCharge}}. New uploads beyond your included storage will be blocked until the next billing cycle or until you increase the cap.',
+ 'storage_overage_cap_reached_title': 'Storage pay-as-you-go cap reached',
'video_generation_completed': 'Your video "{{prompt}}" is ready.',
'video_generation_completed_title': 'Video generation completed',
};
diff --git a/src/locales/default/setting.ts b/src/locales/default/setting.ts
index f3213f98393..34222ca21c9 100644
--- a/src/locales/default/setting.ts
+++ b/src/locales/default/setting.ts
@@ -538,10 +538,12 @@ export default {
'notification.push.desc':
'Send push notifications to your mobile devices (LobeHub mobile app required)',
'notification.push.title': 'Mobile Push Notifications',
+ 'notification.category.billing.title': 'Billing',
'notification.category.generation.title': 'Generation',
'notification.category.schedule.title': 'Scheduled tasks',
'notification.item.agent_cron_job_failed': 'Scheduled task failed',
'notification.item.image_generation_completed': 'Image generation completed',
+ 'notification.item.storage_overage_cap_reached': 'Storage pay-as-you-go cap reached',
'notification.item.video_generation_completed': 'Video generation completed',
'notification.title': 'Notification Channels',
'myAgents.actions.cancel': 'Cancel',
@@ -976,6 +978,54 @@ When I am ___, I need ___
'storage.embeddings.used': 'Vector Storage',
'storage.title': 'Data Storage',
'storage.used': 'Storage Usage',
+ 'storageOverage.addPaymentMethod': 'Add payment method',
+ 'storageOverage.capped': 'Monthly spending cap reached. Overage uploads are paused.',
+ 'storageOverage.capUpdateFailed': 'Failed to update monthly cap.',
+ 'storageOverage.capUpdated': 'Monthly cap updated.',
+ 'storageOverage.consent.billedMonthlyForYearly':
+ 'Storage overage is billed monthly, separate from your yearly plan renewal',
+ 'storageOverage.consent.billedTogether': 'Billed together with your subscription',
+ 'storageOverage.consent.canDisable': 'Can be disabled anytime',
+ 'storageOverage.consent.description': 'Storage exceeding your plan quota will be charged:',
+ 'storageOverage.consent.enable': 'Agree and enable',
+ 'storageOverage.consent.onlyOverage': 'Only overage is charged',
+ 'storageOverage.consent.rate':
+ 'About {{limitedMonthlyRate}}/GB/month for a limited time (regular {{regularMonthlyRate}}).',
+ 'storageOverage.consent.title': 'Enable Storage Pay-as-you-go',
+ 'storageOverage.currentPlanLocked.desc':
+ 'Your current plan does not support storage pay-as-you-go. After it ends, subscribe to a plan to enable it.',
+ 'storageOverage.desc':
+ 'Subscription plans can enable metered billing for storage beyond the included quota.',
+ 'storageOverage.disableConfirm.blockUploads':
+ 'If your storage is still above the included quota, new uploads will be blocked.',
+ 'storageOverage.disableConfirm.canEnableAgain':
+ 'You can enable storage pay-as-you-go again later.',
+ 'storageOverage.disableConfirm.confirm': 'Disable',
+ 'storageOverage.disableConfirm.description':
+ 'After disabling, storage overage will no longer be billed.',
+ 'storageOverage.disableConfirm.existingCharges':
+ 'Charges already incurred in this billing cycle will still be included on your subscription invoice.',
+ 'storageOverage.disableConfirm.title': 'Disable storage pay-as-you-go?',
+ 'storageOverage.disableFailed': 'Failed to disable storage pay-as-you-go.',
+ 'storageOverage.disabled': 'Storage pay-as-you-go disabled.',
+ 'storageOverage.enableFailed': 'Failed to enable storage pay-as-you-go.',
+ 'storageOverage.enabled': 'Storage pay-as-you-go enabled.',
+ 'storageOverage.monthlyCap': 'Monthly Spending Cap',
+ 'storageOverage.monthlyCapDesc':
+ 'Leave empty for unlimited. Uploads will be blocked when the cap is reached.',
+ 'storageOverage.noPaymentMethod': 'Please add a payment method to enable storage pay-as-you-go.',
+ 'storageOverage.rate':
+ 'About {{limitedMonthlyRate}}/GB/month for a limited time (regular {{regularMonthlyRate}}).',
+ 'storageOverage.subscriptionRequired.action': 'View plans',
+ 'storageOverage.subscriptionRequired.desc':
+ 'Subscribe to a plan to enable storage pay-as-you-go for overage usage.',
+ 'storageOverage.title': 'File Storage Pay-as-you-go',
+ 'storageOverage.toggle': 'Enable overage billing',
+ 'storageOverage.unlimited': 'Unlimited',
+ 'storageOverage.usage.current': 'Usage',
+ 'storageOverage.usage.estimatedCharge': 'Est. Cycle Charge',
+ 'storageOverage.usage.incurredCharge': 'Incurred This Cycle',
+ 'storageOverage.usage.overage': 'Overage',
'submitAgentModal.button': 'Submit Agent',
'submitAgentModal.identifier': 'Agent Identifier',
'submitAgentModal.metaMiss':
diff --git a/src/locales/default/subscription.ts b/src/locales/default/subscription.ts
index a19cda32a42..30e0c1ce804 100644
--- a/src/locales/default/subscription.ts
+++ b/src/locales/default/subscription.ts
@@ -300,6 +300,7 @@ export default {
'plans.features.showAll': 'View All Features',
'plans.features.title': 'Premium Features',
'plans.fileStorage.title': 'File Storage',
+ 'plans.fileStorage.storagePayAsYouGo': 'Storage overages support pay-as-you-go billing',
'plans.fileStorage.tooltip': 'File storage for storing files, images, and other data',
'plans.free': 'Free',
'plans.freeTrail': 'Register to get free trial of {{name}}, no credit card required',
@@ -327,7 +328,7 @@ export default {
'plans.payonce.cancel': 'Cancel',
'plans.payonce.ok': 'Confirm Selection',
'plans.payonce.popconfirm':
- 'After one-time payment, you can upgrade anytime but downgrade requires waiting for expiration. Please confirm your selection.',
+ 'After one-time payment, you can upgrade anytime, but downgrade requires waiting for expiration. Storage pay-as-you-go is not supported. Please confirm your selection.',
'plans.payonce.tooltip':
'One-time payment only supports upgrading to a higher tier or longer duration',
'plans.payonce.upgradeOk': 'Confirm Upgrade',
@@ -461,10 +462,16 @@ export default {
'referral.table.status.suspected': 'Suspected Anomaly',
'referral.table.title': 'Referral History',
'sessionCard.title': 'Ready to leave the free plan? Upgrade to enjoy premium features.',
- 'summary.desc': 'This amount only includes subscription service expenses.',
+ 'summary.annualRenewal': 'Annual plan renewal: {{amount}} on {{date}}',
+ 'summary.desc':
+ 'This amount includes your subscription fee and any storage overage charges for this billing period.',
'summary.dueBy': 'Due on {{date}}',
+ 'summary.nextMonthlyPayment': 'Your Next Monthly Payment',
'summary.nextPayment': 'Your Next Payment',
'summary.paymentInformation': 'Billing Information',
+ 'summary.storageSettings': 'Storage pay-as-you-go',
+ 'summary.storageMonthlyDesc':
+ 'This amount covers storage overage for the current monthly billing period.',
'summary.title': 'Billing Summary',
'summary.usageThisMonth': 'View your usage this month.',
'summary.viewBillingHistory': 'View Payment History',
diff --git a/src/server/routers/lambda/index.ts b/src/server/routers/lambda/index.ts
index 7ea5eaf037f..cf77836f5cc 100644
--- a/src/server/routers/lambda/index.ts
+++ b/src/server/routers/lambda/index.ts
@@ -5,6 +5,7 @@ import { accountDeletionRouter } from '@/business/server/lambda-routers/accountD
import { pageShareRouter } from '@/business/server/lambda-routers/pageShare';
import { referralRouter } from '@/business/server/lambda-routers/referral';
import { spendRouter } from '@/business/server/lambda-routers/spend';
+import { storageOverageRouter } from '@/business/server/lambda-routers/storageOverage';
import { subscriptionRouter } from '@/business/server/lambda-routers/subscription';
import { taskTemplateRouter } from '@/business/server/lambda-routers/taskTemplate';
import { topUpRouter } from '@/business/server/lambda-routers/topUp';
@@ -135,6 +136,7 @@ export const lambdaRouter = router({
pageShare: pageShareRouter,
referral: referralRouter,
spend: spendRouter,
+ storageOverage: storageOverageRouter,
subscription: subscriptionRouter,
taskTemplate: taskTemplateRouter,
topUp: topUpRouter,
diff --git a/src/store/file/slices/upload/action.test.ts b/src/store/file/slices/upload/action.test.ts
index 740c473d03e..6acbb849175 100644
--- a/src/store/file/slices/upload/action.test.ts
+++ b/src/store/file/slices/upload/action.test.ts
@@ -1,7 +1,8 @@
import { act, renderHook } from '@testing-library/react';
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
-import { message } from '@/components/AntdStaticMethods';
+import { handleFileUploadError } from '@/business/client/handleFileUploadError';
+import { message, notification } from '@/components/AntdStaticMethods';
import { fileService } from '@/services/file';
import { uploadService } from '@/services/upload';
import { getImageDimensions } from '@/utils/client/imageDimensions';
@@ -15,6 +16,13 @@ vi.mock('@/components/AntdStaticMethods', () => ({
message: {
info: vi.fn(),
},
+ notification: {
+ error: vi.fn(),
+ },
+}));
+
+vi.mock('@/business/client/handleFileUploadError', () => ({
+ handleFileUploadError: vi.fn(),
}));
vi.mock('@/utils/client/imageDimensions', () => ({
@@ -44,6 +52,7 @@ beforeAll(() => {
beforeEach(() => {
vi.clearAllMocks();
+ vi.mocked(handleFileUploadError).mockReturnValue(false);
});
afterEach(() => {
@@ -152,6 +161,37 @@ describe('FileUploadAction', () => {
}),
).rejects.toThrow('Upload failed');
});
+
+ it('should delegate handled base64 upload errors to the business upload error handler', async () => {
+ const { result } = renderHook(() => useStore());
+
+ const base64Data = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA';
+ const mockMetadata = {
+ date: '12345',
+ dirname: '/test',
+ filename: 'test.png',
+ path: '/test/test.png',
+ };
+
+ vi.mocked(getImageDimensions).mockResolvedValue(undefined);
+ vi.spyOn(uploadService, 'uploadBase64ToS3').mockResolvedValue({
+ fileType: 'image/png',
+ hash: 'mock-hash',
+ metadata: mockMetadata,
+ size: 1024,
+ });
+ const uploadError = new Error('business upload blocked');
+ vi.spyOn(fileService, 'createFile').mockRejectedValue(uploadError);
+ vi.mocked(handleFileUploadError).mockReturnValue(true);
+
+ const uploadResult = await act(async () => {
+ return await result.current.uploadBase64FileWithProgress(base64Data);
+ });
+
+ expect(uploadResult).toBeUndefined();
+ expect(handleFileUploadError).toHaveBeenCalledWith(uploadError);
+ expect(notification.error).not.toHaveBeenCalled();
+ });
});
describe('uploadWithProgress', () => {
@@ -692,6 +732,41 @@ describe('FileUploadAction', () => {
});
describe('error handling', () => {
+ it('should delegate handled upload errors to the business upload error handler', async () => {
+ const { uploadWithProgress } = useStore.getState();
+
+ const mockFile = new File(['test content'], 'blocked.png', { type: 'image/png' });
+ const mockCheckResult = { isExist: false };
+ const onStatusUpdate = vi.fn();
+ const uploadError = new Error('business upload blocked');
+
+ vi.mocked(getImageDimensions).mockResolvedValue(undefined);
+ vi.spyOn(fileService, 'checkFileHash').mockResolvedValue(mockCheckResult);
+ vi.spyOn(uploadService, 'uploadFileToS3').mockRejectedValue(uploadError);
+ vi.mocked(handleFileUploadError).mockImplementation((_error, options) => {
+ options?.onUploadBlocked?.();
+ return true;
+ });
+
+ const result = await act(async () => {
+ return await uploadWithProgress({
+ file: mockFile,
+ onStatusUpdate,
+ });
+ });
+
+ expect(result).toBeUndefined();
+ expect(onStatusUpdate).toHaveBeenCalledWith({
+ id: mockFile.name,
+ type: 'removeFile',
+ });
+ expect(handleFileUploadError).toHaveBeenCalledWith(
+ uploadError,
+ expect.objectContaining({ onUploadBlocked: expect.any(Function) }),
+ );
+ expect(notification.error).not.toHaveBeenCalled();
+ });
+
it('should handle checkFileHash errors', async () => {
const { uploadWithProgress } = useStore.getState();
diff --git a/src/store/file/slices/upload/action.ts b/src/store/file/slices/upload/action.ts
index c38d916e523..886d9dc156e 100644
--- a/src/store/file/slices/upload/action.ts
+++ b/src/store/file/slices/upload/action.ts
@@ -3,7 +3,8 @@ import { inferImageMimeTypeFromBytes } from '@lobechat/utils';
import { t } from 'i18next';
import { sha256 } from 'js-sha256';
-import { message, notification } from '@/components/AntdStaticMethods';
+import { handleFileUploadError } from '@/business/client/handleFileUploadError';
+import { message } from '@/components/AntdStaticMethods';
import { fileService } from '@/services/file';
import { uploadService } from '@/services/upload';
import { type StoreSetter } from '@/store/types';
@@ -69,6 +70,7 @@ const normalizeUploadedImageFileType = async (
};
type Setter = StoreSetter<FileStore>;
+
export const createFileUploadSlice = (set: Setter, get: () => FileStore, _api?: unknown) =>
new FileUploadActionImpl(set, get, _api);
@@ -82,20 +84,26 @@ export class FileUploadActionImpl {
uploadBase64FileWithProgress = async (
base64: string,
): Promise<UploadWithProgressResult | undefined> => {
- // Extract image dimensions from base64 data
- const dimensions = await getImageDimensions(base64);
-
- const { metadata, fileType, size, hash } = await uploadService.uploadBase64ToS3(base64);
-
- const res = await fileService.createFile({
- fileType,
- hash,
- metadata,
- name: metadata.filename,
- size,
- url: metadata.path,
- });
- return { ...res, dimensions, filename: metadata.filename };
+ try {
+ // Extract image dimensions from base64 data
+ const dimensions = await getImageDimensions(base64);
+
+ const { metadata, fileType, size, hash } = await uploadService.uploadBase64ToS3(base64);
+
+ const res = await fileService.createFile({
+ fileType,
+ hash,
+ metadata,
+ name: metadata.filename,
+ size,
+ url: metadata.path,
+ });
+ return { ...res, dimensions, filename: metadata.filename };
+ } catch (error) {
+ if (handleFileUploadError(error)) return;
+
+ throw error;
+ }
};
uploadWithProgress = async ({
@@ -199,15 +207,14 @@ export class FileUploadActionImpl {
return { ...data, dimensions, filename: normalizedFile.name };
} catch (error) {
- // Handle file storage plan limit error
- if ((error as any)?.message?.includes('beyond the plan limit')) {
- onStatusUpdate?.({ id: statusId, type: 'removeFile' });
- notification.error({
- description: t('upload.storageLimitExceeded', { ns: 'error' }),
- message: t('upload.uploadFailed', { ns: 'error' }),
- });
+ if (
+ handleFileUploadError(error, {
+ onUploadBlocked: () => onStatusUpdate?.({ id: statusId, type: 'removeFile' }),
+ })
+ ) {
return;
}
+
throw error;
}
};