Azure storage: Uploaded files with size zero bytes

后端 未结 2 2020
野性不改
野性不改 2021-01-17 07:14

When I upload an image file to a blob, the image is uploaded apparently successfully (no errors). When I go to cloud storage studio, the file is there, but with a size of 0

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-17 07:59

    Thanks Fabio for bringing this up and solving your own question. I just want to add code to whatever you have said. Your suggestion worked perfectly for me.

            var memoryStream = new MemoryStream();
    
            // "upload" is the object returned by fine uploader
            upload.InputStream.CopyTo(memoryStream);
            memoryStream.ToArray();
    
    // After copying the contents to stream, initialize it's position
    // back to zeroth location
    
            memoryStream.Seek(0, SeekOrigin.Begin);
    

    And now you are ready to upload memoryStream using:

    blockBlob.UploadFromStream(memoryStream);
    

提交回复
热议问题