OrchardCMS/OrchardCore · error · FileStoreException

You tried to upload a file that requires

Error message

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.

What it means

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.

Solutions

  1. Free up storage by deleting unused media files, then retry.
  2. Increase the permitted storage limit in media/storage settings (or set it higher/unlimited if plan allows).
  3. Compress or resize the file before upload to fit the remaining quota.
  4. Catch FileStoreException in upload UI and surface the quota message to the end user.
Defensive patterns

Strategy: try-catch

Validate before calling

// Check remaining quota before upload
var limit = await GetPermittedStorageAsync();
if (limit.HasValue && fileSizeBytes > limit.Value - usedBytes)
    throw new InvalidOperationException("Upload exceeds available storage quota.");

Try / catch

try
{
    await mediaFileStore.CreateFileAsync(path, stream);
}
catch (FileStoreException ex) when (ex.Message.Contains("storage space"))
{
    // inform user about quota; suggest deleting files or increasing limit
}

Prevention

When it happens

Trigger: CreateFileAsync or CopyFileAsync when GetPermittedStorageAsync returns a limit and the incoming file's size exceeds remaining allowed storage.

Common situations: 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.

Understand the failure class

Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.

Related errors


AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13). Data as JSON: /api/errors/92d2531802bfe3b3. Report an issue: GitHub.

Appendix: source

Thrown at src/OrchardCore/OrchardCore.Media.Core/DefaultMediaFileStore.cs:274

    private void ValidateRequestBasePath(HttpContext httpContext)
    {
        var originalPathBase = httpContext.Features.Get<ShellContextFeature>()?.OriginalPathBase ?? PathString.Empty;
        if (originalPathBase.HasValue)
        {
            var requestBasePath = _requestBasePath;
            if (!requestBasePath.StartsWith(originalPathBase.Value, StringComparison.OrdinalIgnoreCase))
            {
                _requestBasePath = _fileStore.Combine(originalPathBase.Value, requestBasePath);
            }
        }
    }

    private async Task ValidateAvailableStorageAsync(long requiredStorageSpace)
    {
        if (await GetPermittedStorageAsync() is { } storageLimit &&
            requiredStorageSpace > storageLimit)
        {
            throw new FileStoreException(
                $"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.");
        }
    }

    private async Task<string> CreateFileAsync(string path, Stream stream, bool overwrite)
    {
        await ValidateAvailableStorageAsync(stream.Length);

        var result = await _fileStore.CreateFileFromStreamAsync(path, stream, overwrite);

        await _mediaEventHandlers.InvokeAsync((handler, ctx) => handler.MediaCreatedFileAsync(ctx), new MediaCreatedContext { Path = result }, _logger);

        return result;
    }
}

View on GitHub (pinned to 4306c0717f)