{"record":{"id":"92d2531802bfe3b3","repo":"OrchardCMS/OrchardCore","slug":"you-tried-to-upload-a-file-that-requires-filesizehelper","errorCode":null,"errorMessage":"You tried to upload a file that requires {_fileSizeHelper.FormatSize(requiredStorageSpace)} of storage space, but only {_fileSizeHelper.FormatSize(storageLimit)} is available. Try uploading a file that fits the available space, or delete some unnecessary files.","messagePattern":"You tried to upload a file that requires (.+?) of storage space, but only (.+?) is available\\. Try uploading a file that fits the available space, or delete some unnecessary files\\.","errorType":"exception","errorClass":"FileStoreException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.Media.Core/DefaultMediaFileStore.cs","lineNumber":274,"sourceCode":"    private void ValidateRequestBasePath(HttpContext httpContext)\n    {\n        var originalPathBase = httpContext.Features.Get<ShellContextFeature>()?.OriginalPathBase ?? PathString.Empty;\n        if (originalPathBase.HasValue)\n        {\n            var requestBasePath = _requestBasePath;\n            if (!requestBasePath.StartsWith(originalPathBase.Value, StringComparison.OrdinalIgnoreCase))\n            {\n                _requestBasePath = _fileStore.Combine(originalPathBase.Value, requestBasePath);\n            }\n        }\n    }\n\n    private async Task ValidateAvailableStorageAsync(long requiredStorageSpace)\n    {\n        if (await GetPermittedStorageAsync() is { } storageLimit &&\n            requiredStorageSpace > storageLimit)\n        {\n            throw new FileStoreException(\n                $\"You tried to upload a file that requires {_fileSizeHelper.FormatSize(requiredStorageSpace)} of \" +\n                $\"storage space, but only {_fileSizeHelper.FormatSize(storageLimit)} is available. Try uploading \" +\n                $\"a file that fits the available space, or delete some unnecessary files.\");\n        }\n    }\n\n    private async Task<string> CreateFileAsync(string path, Stream stream, bool overwrite)\n    {\n        await ValidateAvailableStorageAsync(stream.Length);\n\n        var result = await _fileStore.CreateFileFromStreamAsync(path, stream, overwrite);\n\n        await _mediaEventHandlers.InvokeAsync((handler, ctx) => handler.MediaCreatedFileAsync(ctx), new MediaCreatedContext { Path = result }, _logger);\n\n        return result;\n    }\n}\n","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.Media.Core/DefaultMediaFileStore.cs#L256-L292","documentation":"DefaultMediaFileStore enforces the tenant/site storage quota. Before creating or copying a file it checks the permitted storage limit; if the required space exceeds it, it throws FileStoreException with a formatted message showing required vs available space.","triggerScenarios":"CreateFileAsync or CopyFileAsync when GetPermittedStorageAsync returns a limit and the incoming file's size exceeds remaining allowed storage.","commonSituations":"Sites with a configured storage limit (e.g. shared hosting or media quota) receiving large uploads; bulk migrations importing many files that collectively exceed the quota; misconfigured or stale quota settings.","solutions":["Free up storage by deleting unused media files, then retry.","Increase the permitted storage limit in media/storage settings (or set it higher/unlimited if plan allows).","Compress or resize the file before upload to fit the remaining quota.","Catch FileStoreException in upload UI and surface the quota message to the end user."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Check remaining quota before upload\nvar limit = await GetPermittedStorageAsync();\nif (limit.HasValue && fileSizeBytes > limit.Value - usedBytes)\n    throw new InvalidOperationException(\"Upload exceeds available storage quota.\");","typeGuard":null,"tryCatchPattern":"try\n{\n    await mediaFileStore.CreateFileAsync(path, stream);\n}\ncatch (FileStoreException ex) when (ex.Message.Contains(\"storage space\"))\n{\n    // inform user about quota; suggest deleting files or increasing limit\n}","preventionTips":["Display remaining quota in upload UIs before users pick files.","Compress/resize large media before upload.","Monitor and prune unused media periodically.","Review storage limit settings when provisioning tenants."],"tags":["media","storage-quota","file-upload"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}