OrchardCMS/OrchardCore · error · FileStoreException

Cannot get file stream because the file

Error message

Cannot get file stream because the file '{path}' does not exist.

What it means

GetFileStreamAsync checks whether the blob exists before downloading; if it does not, it throws FileStoreException with this message. This is an explicit not-found signal distinct from storage service errors, which are wrapped by a separate catch.

Solutions

  1. Verify the path exists first with fileStore.GetFileInfoAsync(path) and return a 404 or fallback instead of opening a stream.
  2. Log and correct the path being passed — check spelling, casing, and whether the directory portion matches the store's BasePath.
  3. Check that the file was not deleted by a concurrent process, workflow, or media cleanup job.
  4. Confirm the tenant's media storage connection settings (container and BasePath) point at the location where files were actually stored.

Example fix

// before
var stream = await fileStore.GetFileStreamAsync(path);
// after
var file = await fileStore.GetFileInfoAsync(path);
if (file == null)
{
    return NotFound();
}
var stream = await fileStore.GetFileStreamAsync(path);
Defensive patterns

Strategy: validation

Validate before calling

var file = await fileStore.GetFileInfoAsync(path);
if (file == null)
{
    return null; // or 404 — blob does not exist
}

Try / catch

try
{
    var stream = await fileStore.GetFileStreamAsync(path);
}
catch (FileStoreException)
{
    return Results.NotFound($"File '{path}' not found.");
}

Prevention

When it happens

Trigger: Calling IFileStore.GetFileStreamAsync(path) (string overload) for a path whose blob does not exist in the container — e.g. path is null/empty, misspelled, points to a directory, or the file was deleted concurrently.

Common situations: Rendering media items whose stored URL references a deleted blob; case-sensitivity mismatches on the blob path (Azure paths are case-sensitive); tenant BasePath misconfiguration so relative paths miss the actual blobs.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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

Appendix: source

Thrown at src/OrchardCore/OrchardCore.FileStorage.AzureBlob/BlobFileStore.cs:637

        catch (FileStoreException)
        {
            throw;
        }
        catch (Exception ex)
        {
            throw new FileStoreException($"Cannot copy file '{srcPath}' to '{dstPath}'.", ex);
        }
    }

    public async Task<Stream> GetFileStreamAsync(string path)
    {
        try
        {
            var blob = GetBlobReference(path);

            if (!await blob.ExistsAsync())
            {
                throw new FileStoreException($"Cannot get file stream because the file '{path}' does not exist.");
            }

            return (await blob.DownloadAsync()).Value.Content;
        }
        catch (FileStoreException)
        {
            throw;
        }
        catch (Exception ex)
        {
            throw new FileStoreException($"Cannot get file stream of the file '{path}'.", ex);
        }
    }

    // Reduces the need to call blob.FetchAttributes, and blob.ExistsAsync,
    // as Azure Storage Library will perform these actions on OpenReadAsync().
    public Task<Stream> GetFileStreamAsync(IFileStoreEntry fileStoreEntry)
    {

View on GitHub (pinned to 4306c0717f)