简体   繁体   中英

How to upload stream with Azure.Storage.Blobs

I'm trying to upload/store data into an azure blob. The data is generated from a xmlSerialize object. Since the result can be big and I don't need the serialized output in my program I would like to stream the data directly into the blob. This has been solved with Microsoft.Azure.Storage.Blob : uploading-datatable-to-azure-blob-storage But I'm using Azure.Storage.Blobs since Microsoft is recommending it and the other has been replaced. Also it supports auth with Identity.

The previews solution relied on getting the stream object for the blob so it could be used by the serializer. But I don't see any way to do the same with the new API. Am I missing something?

But I don't see any way to do the same with the new API. Am I missing something?

You're correct. Getting a stream object for the blob is not available in the new SDK. You will need to convert the data into stream and then use Upload or UploadAsync method on BlobClient or BlockBlobClient to upload the blob.

See answer at https://stackoverflow.com/a/65395088/2589083

new Azure.Storage.Blobs.Specialized.BlockBlobClient(System.Uri uri)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM