{"record":{"id":"575ad24daaccaadd","repo":"abpframework/abp","slug":"specified-method-is-not-supported","errorCode":null,"errorMessage":"Specified method is not supported.","messagePattern":"Specified method is not supported\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"framework/src/Volo.Abp.BlobStoring.Aws/Volo/Abp/BlobStoring/Aws/LeaveOpenStreamWrapper.cs","lineNumber":86,"sourceCode":"        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\n        return _inner.ReadAsync(buffer.AsMemory(offset, count), cancellationToken).AsTask();\n#endif\n    }\n\n#if !NETSTANDARD2_0\n    public override int Read(Span<byte> buffer) => _inner.Read(buffer);\n\n    public override ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken = default)\n    {\n        return _inner.ReadAsync(buffer, cancellationToken);\n    }\n#endif\n\n    public override long Seek(long offset, SeekOrigin origin) => _inner.Seek(offset, origin);\n    public override void SetLength(long value) => throw new NotSupportedException();\n    public override void Write(byte[] buffer, int offset, int count) => throw new NotSupportedException();\n\n    // Disposing the wrapper must not dispose the wrapped stream\n}\n","sourceCodeStart":68,"sourceCodeEnd":91,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.BlobStoring.Aws/Volo/Abp/BlobStoring/Aws/LeaveOpenStreamWrapper.cs#L68-L91","documentation":"LeaveOpenStreamWrapper.SetLength and Write throw a bare NotSupportedException (whose default .NET message is 'Specified method is not supported.'). The wrapper is intentionally read-only (CanWrite is hardcoded false) because it exists solely to feed bytes to the AWS SDK upload without surrendering ownership of the underlying stream. Any attempt to mutate length or write through it is rejected.","triggerScenarios":"Calling SetLength or Write (or WriteAsync via the base) on a LeaveOpenStreamWrapper instance. This happens when code mistakenly treats the wrapper as a writable stream, or when a stream-copy helper tries to write into it.","commonSituations":"Custom code that wraps the AWS provider and attempts to write back into the upload stream, misuse of the internal wrapper, or a generic stream-processing utility that writes to whatever Stream it receives.","solutions":["Do not write to or set length on the wrapper; it is an upload-only forwarder.","If you need a readable+writable stream, use a MemoryStream instead of the wrapper.","Keep the LeaveOpenStreamWrapper internal to the AWS provider path and never expose it to callers."],"exampleFix":"// before (incorrect)\nwrapper.Write(buffer, 0, buffer.Length);\n\n// after\nusing var memStream = new MemoryStream();\nmemStream.Write(buffer, 0, buffer.Length);\nmemStream.Position = 0;\nawait container.SaveAsync(name, memStream);","handlingStrategy":"validation","validationCode":"// Never call Write/SetLength on LeaveOpenStreamWrapper. If you need a writable stream:\nvar writable = new MemoryStream();\nwritable.Write(buffer, 0, buffer.Length);\nwritable.Position = 0;\nawait container.SaveAsync(name, writable);","typeGuard":"if (!stream.CanWrite) throw new InvalidOperationException(\"Stream is not writable; cannot Write/SetLength.\");","tryCatchPattern":"try { wrapper.Write(buffer, 0, buffer.Length); }\ncatch (NotSupportedException) { /* do not write to the read-only wrapper */ }","preventionTips":["Treat LeaveOpenStreamWrapper as read-only upload forwarder.","Do not expose internal provider wrappers to application code.","Use MemoryStream when a writable buffer is required."],"tags":["aws","stream","read-only","blob-storage","abp"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}