{"record":{"id":"f184ffdcbb50c25f","repo":"abpframework/abp","slug":"the-position-of-the-stream-is-not-available","errorCode":null,"errorMessage":"The position of the stream is not available!","messagePattern":"The position of the stream is not available!","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"warning","filePath":"framework/src/Volo.Abp.BlobStoring.Aws/Volo/Abp/BlobStoring/Aws/LeaveOpenStreamWrapper.cs","lineNumber":53,"sourceCode":"            }\n            catch (IOException ex)\n            {\n                throw new NotSupportedException(\"The length of the stream is not available!\", ex);\n            }\n        }\n    }\n\n    public override long Position\n    {\n        get\n        {\n            try\n            {\n                return _inner.Position;\n            }\n            catch (IOException ex)\n            {\n                throw new NotSupportedException(\"The position of the stream is not available!\", ex);\n            }\n        }\n        set => _inner.Position = value;\n    }\n\n    public override void Flush()\n    {\n    }\n\n    public override int Read(byte[] buffer, int offset, int count) => _inner.Read(buffer, offset, count);\n\n    public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)\n    {\n#if NETSTANDARD2_0\n        return _inner.ReadAsync(buffer, offset, count, cancellationToken);\n#else\n        // The SDK reads over this (old) overload; dispatch it over the modern one,\n        // so a source that only implements ReadAsync(Memory<byte>) keeps working","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.BlobStoring.Aws/Volo/Abp/BlobStoring/Aws/LeaveOpenStreamWrapper.cs#L35-L71","documentation":"LeaveOpenStreamWrapper.Position getter re-throws an IOException from the inner stream as a NotSupportedException ('The position of the stream is not available!'). It mirrors the Length translation so the AWS SDK (which only handles NotSupportedException on Position probes) degrades gracefully to 'unknown position' rather than failing the upload. The original IOException is kept as InnerException; the setter still delegates to the inner stream.","triggerScenarios":"During a wrapped AWS upload the SDK reads the Position property of the LeaveOpenStreamWrapper and the inner stream throws IOException (non-seekable / network-backed stream). The wrapper translates it so the upload can continue without a known position.","commonSituations":"Uploading from a forward-only stream that cannot report Position, or a stream whose Position accessor throws. Normally absorbed by the SDK; surfaces only if code outside the SDK probes Position.","solutions":["Buffer the source into a seekable MemoryStream so Position is always readable.","Let the SDK continue with unknown position (the translation exists for that case).","Provide a seekable stream when the upload path requires resuming/seeking."],"exampleFix":"// before\nawait container.SaveAsync(name, forwardOnlyStream);\n\n// after\nusing var buffer = new MemoryStream();\nawait forwardOnlyStream.CopyToAsync(buffer);\nbuffer.Position = 0;\nawait container.SaveAsync(name, buffer);","handlingStrategy":"fallback","validationCode":"Stream uploadStream = sourceStream;\nif (!sourceStream.CanSeek)\n{\n    using var buffer = new MemoryStream();\n    await sourceStream.CopyToAsync(buffer);\n    buffer.Position = 0;\n    uploadStream = buffer;\n}\nawait container.SaveAsync(name, uploadStream);","typeGuard":"bool positionAvailable = sourceStream.CanSeek;","tryCatchPattern":"catch (NotSupportedException ex) when (ex.Message.Contains(\"position of the stream\"))\n{\n    using var buffer = new MemoryStream();\n    await sourceStream.CopyToAsync(buffer); buffer.Position = 0;\n    await container.SaveAsync(name, buffer);\n}","preventionTips":["Use seekable streams so Position is reportable.","Buffer forward-only streams before upload.","Remember the wrapper is read-only and exists to protect stream ownership."],"tags":["aws","stream","blob-storage","upload","abp"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}