OrchardCMS/OrchardCore · error · FileStoreException
Cannot create file ' '.
Error message
Cannot create file '{path}'. What it means
CreateFileFromStreamAsync wraps any non-FileStoreException failure while uploading the blob (content-type resolution, OpenWrite/Upload of the stream, HTTP headers) in a FileStoreException with this message. The inner exception contains the underlying Azure Storage error.
Solutions
- Inspect the InnerException (RequestFailedException Status) for the actual cause: 403 auth, 404 container missing, 429 throttling, 400 bad request/path.
- Verify the input stream is readable, not disposed, and positioned at 0 before calling.
- Check the storage connection string, account status, and that the target container exists.
- Validate the path contains only valid blob name characters and proper forward-slash separators.
Example fix
// before
await fileStore.CreateFileFromStreamAsync(path, stream);
// after
if (!stream.CanRead)
{
throw new InvalidOperationException("Input stream is not readable.");
}
stream.Position = 0;
await fileStore.CreateFileFromStreamAsync(path, stream); Defensive patterns
Strategy: try-catch
Validate before calling
if (!stream.CanRead) throw new InvalidOperationException("Stream not readable");
stream.Position = 0;
foreach (var c in Path.GetInvalidFileNameChars())
{
path = path.Replace(c, '_');
} Try / catch
try
{
await fileStore.CreateFileFromStreamAsync(path, stream);
}
catch (FileStoreException ex)
{
logger.LogError(ex.InnerException, "Create failed for {Path}", path);
throw;
} Prevention
- Reset stream position and validate readability before upload
- Verify connection string and container existence
- Strip invalid path characters from user-supplied names
- Distinguish FileStoreException (pre-check) from wrapped storage errors via InnerException
When it happens
Trigger: Calling IFileStore.CreateFileFromStreamAsync(path, stream) when the Azure SDK upload throws: auth failure, container missing, invalid path characters, zero/disposed input stream, throttling, or exceeding storage limits.
Common situations: Bad storage connection string or disabled account; media uploads during a storage outage; passing a stream that was already disposed or empty by an upstream bug; blob names with characters Azure rejects (e.g. '\\', trailing dot).
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- Cannot copy file ' ' to ' '.
- Cannot get file stream of the file
- Cannot create a stream for a directory.
- Error retrieving file info for
- Error creating directory
AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13).
Data as JSON: /api/errors/8665d7608a6ba545.
Report an issue: GitHub.
Appendix: source
Thrown at src/OrchardCore/OrchardCore.FileStorage.AzureBlob/BlobFileStore.cs:687
_contentTypeProvider.TryGetContentType(path, out var contentType);
var headers = new BlobHttpHeaders
{
ContentType = contentType ?? MediaTypeNames.Application.Octet,
};
await blob.UploadAsync(inputStream, headers);
return path;
}
catch (FileStoreException)
{
throw;
}
catch (Exception ex)
{
throw new FileStoreException($"Cannot create file '{path}'.", ex);
}
}
private BlobClient GetBlobReference(string path)
{
var blobPath = this.Combine(_options.BasePath, path);
var blob = _blobContainer.GetBlobClient(blobPath);
return blob;
}
private async Task<BlobHierarchyItem> GetBlobDirectoryReference(string path)
{
var prefix = this.Combine(_basePrefix, path);
prefix = NormalizePrefix(prefix);
// Directory exists if path contains any files.
var page = _blobContainer.GetBlobsByHierarchyAsync(BlobTraits.Metadata, BlobStates.None, "/", prefix, CancellationToken.None);View on GitHub (pinned to 4306c0717f)