{"record":{"id":"8665d7608a6ba545","repo":"OrchardCMS/OrchardCore","slug":"cannot-create-file-path-blobfilestore","errorCode":null,"errorMessage":"Cannot create file '{path}'.","messagePattern":"Cannot create file '(.+?)'\\.","errorType":"exception","errorClass":"FileStoreException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.FileStorage.AzureBlob/BlobFileStore.cs","lineNumber":687,"sourceCode":"\n            _contentTypeProvider.TryGetContentType(path, out var contentType);\n\n            var headers = new BlobHttpHeaders\n            {\n                ContentType = contentType ?? MediaTypeNames.Application.Octet,\n            };\n\n            await blob.UploadAsync(inputStream, headers);\n\n            return path;\n        }\n        catch (FileStoreException)\n        {\n            throw;\n        }\n        catch (Exception ex)\n        {\n            throw new FileStoreException($\"Cannot create file '{path}'.\", ex);\n        }\n    }\n\n    private BlobClient GetBlobReference(string path)\n    {\n        var blobPath = this.Combine(_options.BasePath, path);\n        var blob = _blobContainer.GetBlobClient(blobPath);\n\n        return blob;\n    }\n\n    private async Task<BlobHierarchyItem> GetBlobDirectoryReference(string path)\n    {\n        var prefix = this.Combine(_basePrefix, path);\n        prefix = NormalizePrefix(prefix);\n\n        // Directory exists if path contains any files.\n        var page = _blobContainer.GetBlobsByHierarchyAsync(BlobTraits.Metadata, BlobStates.None, \"/\", prefix, CancellationToken.None);","sourceCodeStart":669,"sourceCodeEnd":705,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.FileStorage.AzureBlob/BlobFileStore.cs#L669-L705","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","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."],"exampleFix":"// before\nawait fileStore.CreateFileFromStreamAsync(path, stream);\n// after\nif (!stream.CanRead)\n{\n    throw new InvalidOperationException(\"Input stream is not readable.\");\n}\nstream.Position = 0;\nawait fileStore.CreateFileFromStreamAsync(path, stream);","handlingStrategy":"try-catch","validationCode":"if (!stream.CanRead) throw new InvalidOperationException(\"Stream not readable\");\nstream.Position = 0;\nforeach (var c in Path.GetInvalidFileNameChars())\n{\n    path = path.Replace(c, '_');\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    await fileStore.CreateFileFromStreamAsync(path, stream);\n}\ncatch (FileStoreException ex)\n{\n    logger.LogError(ex.InnerException, \"Create failed for {Path}\", path);\n    throw;\n}","preventionTips":["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"],"tags":["azure-blob-storage","file-write","io"],"backgroundTag":"file-write-failed","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"}