{"record":{"id":"76a9887cb9b2d587","repo":"OrchardCMS/OrchardCore","slug":"error-getting-file-stream-for-path-ex-message","errorCode":null,"errorMessage":"Error getting file stream for '{path}': {ex.Message}","messagePattern":"Error getting file stream for '(.+?)': (.+?)","errorType":"exception","errorClass":"FileStoreException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.FileStorage.AmazonS3/AwsFileStorage.cs","lineNumber":264,"sourceCode":"        {\n            throw new FileStoreException($\"Error while copying file '{srcPath}': {ex.Message}\", ex);\n        }\n    }\n\n    public Task<Stream> GetFileStreamAsync(string path)\n    {\n        try\n        {\n            var transferUtility = new TransferUtility(_amazonS3Client);\n            return transferUtility.OpenStreamAsync(_options.BucketName, this.Combine(_basePrefix, path));\n        }\n        catch (AmazonS3Exception ex) when (ex.StatusCode == HttpStatusCode.NotFound)\n        {\n            throw new FileStoreException($\"Cannot get file stream because the file '{path}' does not exist.\");\n        }\n        catch (AmazonS3Exception ex)\n        {\n            throw new FileStoreException($\"Error getting file stream for '{path}': {ex.Message}\", ex);\n        }\n    }\n\n    public Task<Stream> GetFileStreamAsync(IFileStoreEntry fileStoreEntry)\n    {\n        return GetFileStreamAsync(fileStoreEntry.Path);\n    }\n\n    public async Task<string> CreateFileFromStreamAsync(string path, Stream inputStream, bool overwrite = false)\n    {\n        try\n        {\n            if (!overwrite)\n            {\n                var listObjects = await _amazonS3Client.ListObjectsV2Async(new ListObjectsV2Request\n                {\n                    BucketName = _options.BucketName,\n                    Prefix = this.Combine(_basePrefix, path),","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.FileStorage.AmazonS3/AwsFileStorage.cs#L246-L282","documentation":"Any AmazonS3Exception from GetFileStreamAsync other than 404 is wrapped in FileStoreException 'Error getting file stream for ...' with the S3 message and inner exception. It reports general failures (auth, permissions, network) while opening the object stream.","triggerScenarios":"GetFileStreamAsync when TransferUtility.OpenStreamAsync throws non-404 errors: AccessDenied, invalid credentials, wrong region/endpoint, network timeouts, throttling.","commonSituations":"IAM policy missing s3:GetObject, expired or rotated credentials, VPC endpoint/proxy blocking S3, bucket region mismatch, transient AWS throttling under load.","solutions":["Read the inner exception message to identify the S3 error code (AccessDenied, SlowDown, etc.).","Verify credentials and IAM s3:GetObject permission for the bucket/prefix.","Match the configured region/service URL to the bucket region.","Add retry with backoff for throttling or transient 5xx errors."],"exampleFix":"// before\nvar stream = await fileStore.GetFileStreamAsync(path);\n\n// after\ntry\n{\n    var stream = await fileStore.GetFileStreamAsync(path);\n}\ncatch (FileStoreException ex) when (ex.Message.Contains(\"AccessDenied\"))\n{\n    _logger.LogError(ex, \"Access denied reading '{Path}' from S3\", path);\n    throw;\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    return await fileStore.GetFileStreamAsync(path);\n}\ncatch (FileStoreException ex) when (ex.Message.Contains(\"SlowDown\") || ex.Message.Contains(\"ServiceUnavailable\"))\n{\n    await Task.Delay(TimeSpan.FromSeconds(1));\n    return await fileStore.GetFileStreamAsync(path);\n}","preventionTips":["Verify IAM s3:GetObject permissions before deploying.","Use IAM roles instead of long-lived static credentials.","Add retry/backoff for throttling errors.","Align service URL region with bucket region."],"tags":["s3","aws","permissions","stream"],"backgroundTag":"api-error-response","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"}