abpframework/abp · warning · NotSupportedException
The length of the stream is not available!
Error message
The length of the stream is not available!
What it means
LeaveOpenStreamWrapper.Length re-throws an IOException from the inner stream as a NotSupportedException with the message 'The length of the stream is not available!'. This is an intentional translation: the AWS SDK's multipart path probes Length but only catches NotSupportedException, so converting an IOException probe failure lets the upload proceed with an 'unknown length' instead of failing. The original IOException is preserved as the InnerException.
Source
Thrown at framework/src/Volo.Abp.BlobStoring.Aws/Volo/Abp/BlobStoring/Aws/LeaveOpenStreamWrapper.cs:38
public override bool CanRead => _inner.CanRead;
public override bool CanSeek => _inner.CanSeek;
public override bool CanWrite => false;
// The SDK computes the optional content length from Length/Position, but only
// handles NotSupportedException; translate an IOException of a probe, so an
// unknown length stays "unknown" instead of failing the upload
public override long Length
{
get
{
try
{
return _inner.Length;
}
catch (IOException ex)
{
throw new NotSupportedException("The length of the stream is not available!", ex);
}
}
}
public override long Position
{
get
{
try
{
return _inner.Position;
}
catch (IOException ex)
{
throw new NotSupportedException("The position of the stream is not available!", ex);
}
}
set => _inner.Position = value;View on GitHub (pinned to 7ed43b1931)
Solutions
- If you control the source, buffer it into a MemoryStream first so Length is always available.
- Allow the SDK to continue with unknown length (this translation exists precisely for that) unless the exception escapes the SDK path.
- Ensure the source stream is seekable when deterministic content length is required for the upload.
Example fix
// before (length probe can throw) await container.SaveAsync(name, networkStream); // after (buffer so Length is reliable) using var buffer = new MemoryStream(); await networkStream.CopyToAsync(buffer); buffer.Position = 0; await container.SaveAsync(name, buffer);
Defensive patterns
Strategy: fallback
Validate before calling
Stream uploadStream = sourceStream;
if (!sourceStream.CanSeek)
{
using var buffer = new MemoryStream();
await sourceStream.CopyToAsync(buffer);
buffer.Position = 0;
uploadStream = buffer;
}
await container.SaveAsync(name, uploadStream); Type guard
bool lengthAvailable = sourceStream.CanSeek; // seekable streams reliably report Length
Try / catch
// The wrapper intentionally translates IOException->NotSupportedException so the SDK
// continues with unknown length. If it escapes, buffer the source and retry:
catch (NotSupportedException ex) when (ex.Message.Contains("length of the stream"))
{
using var buffer = new MemoryStream();
await sourceStream.CopyToAsync(buffer); buffer.Position = 0;
await container.SaveAsync(name, buffer);
} Prevention
- Buffer non-seekable/network streams into a MemoryStream before saving.
- Prefer seekable streams so Length is deterministic.
- Be aware the AWS provider wraps your stream in LeaveOpenStreamWrapper internally.
When it happens
Trigger: The AWS blob provider wraps the source BlobStream in LeaveOpenStreamWrapper; when the SDK reads the Length property and the inner stream throws IOException (e.g. a network-backed or non-seekable stream whose Length is not supported), the wrapper translates it. The SDK then treats the length as unknown and continues.
Common situations: Saving from a forward-only network stream, an unbuffered HTTP request body, or a stream whose Length accessor genuinely throws IOException. Normally benign (the upload continues), but it surfaces if consumer code outside the SDK reads Length directly.
Related errors
- The position of the stream is not available!
- Specified method is not supported.
- Saving BLOB '{args.BlobName}' does already exists in the con
- Saving BLOB '{args.BlobName}' does already exists in the con
- Either Region or ServiceURL must be configured on AwsBlobPro
AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13).
Data as JSON: /api/errors/602cefa91070e4df.
Report an issue: GitHub.