|
38 | 38 | import com.azure.storage.blob.options.BlockBlobSimpleUploadOptions; |
39 | 39 | import com.azure.storage.blob.options.BlockBlobStageBlockFromUrlOptions; |
40 | 40 | import com.azure.storage.blob.options.BlockBlobStageBlockOptions; |
| 41 | +import com.azure.storage.common.Utility; |
41 | 42 | import com.azure.storage.common.implementation.Constants; |
42 | 43 | import com.azure.storage.common.implementation.StorageImplUtils; |
43 | 44 | import com.azure.storage.common.implementation.StorageSeekableByteChannel; |
| 45 | +import reactor.core.publisher.Flux; |
44 | 46 | import reactor.core.publisher.Mono; |
45 | 47 |
|
46 | 48 | import java.io.InputStream; |
47 | 49 | import java.io.UncheckedIOException; |
48 | 50 | import java.net.URL; |
| 51 | +import java.nio.ByteBuffer; |
49 | 52 | import java.nio.channels.SeekableByteChannel; |
50 | 53 | import java.time.Duration; |
51 | 54 | import java.util.List; |
@@ -783,10 +786,13 @@ public Response<Void> stageBlockWithResponse(String base64BlockId, InputStream d |
783 | 786 | String leaseId, Duration timeout, Context context) { |
784 | 787 | StorageImplUtils.assertNotNull("data", data); |
785 | 788 |
|
786 | | - Mono<Response<Void>> response = client.stageBlockWithResponseInternal( |
787 | | - new BlockBlobStageBlockOptions(base64BlockId, BinaryData.fromStream(data, length)).setContentMd5(contentMd5) |
788 | | - .setLeaseId(leaseId), |
789 | | - context); |
| 789 | + Flux<ByteBuffer> fbb |
| 790 | + = Utility.convertStreamToByteBuffer(data, length, BlobAsyncClient.BLOB_DEFAULT_UPLOAD_BLOCK_SIZE, true); |
| 791 | + |
| 792 | + Mono<Response<Void>> response = BinaryData.fromFlux(fbb, length, false) |
| 793 | + .flatMap(binaryData -> client.stageBlockWithResponseInternal( |
| 794 | + new BlockBlobStageBlockOptions(base64BlockId, binaryData).setContentMd5(contentMd5).setLeaseId(leaseId), |
| 795 | + context)); |
790 | 796 | return blockWithOptionalTimeout(response, timeout); |
791 | 797 | } |
792 | 798 |
|
|
0 commit comments