[FEATURE REQ] BlobClient.upload(InputStream, ...) shouldn't require a known length #20567
Labels
Client
This issue points to a problem in the data-plane of the library.
feature-request
This issue requires a new behavior in the product in order be resolved.
Storage
Storage Service (Queues, Blobs, Files)
There are no sync upload methods which take an InputStream and don't require the user to submit a known length of that InputStream. However, the async equivalents don't need this. They don't even allow it to be set because the code wouldn't use it; once the library has a Flux a known length is irrelevant. Sync upload needs this because
com.azure.storage.common.Utility.convertStreamToByteBuffer()
needs a length to function with it's current implementation.The method currently requires a length because (deferred until subscription on the return type) it opens out the conversion with
Flux.range(0, (int) Math.ceil((double) length / (double) blockSize)).map(i -> i * blockSize)
and then transforms that flux intoInputStream
reads of that size. We should be able to useFlux.push()
or a similar method to return a Flux where subscription triggers a synchronous function that consumes the stream into ByteBuffers and pushes those out to subscribers. Care would need to be taken in writing the synchronous stream consumption such that each call doesn't read too much of the InputStream, building up memory and blocking other reactive steps from taking place (when Reactor is operating on one thread). With this, the stream is just read until completion and converted into the Flux the SDK already know how to handle indefinitely.The text was updated successfully, but these errors were encountered: