Azure blob下载为字节数组错误“内存流不可扩展” [英] Azure blob download as byte array error “memory stream is not expandable”

查看:255
本文介绍了Azure blob下载为字节数组错误“内存流不可扩展”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将blob作为字节数组下载,但上面提到错误。我的代码如下





 Dim fullFileBytes()As Byte = {} 
Dim objAzureStorage As新的AzureCloudStorage

Dim fullImageBlob As Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob = objAzureStorage.CloudContainer.GetBlockBlobReference(row(0))

fullImageBlob.DownloadToByteArray(fullFileBytes,0)





我的尝试:



我得到blob流并将其转换为byte。

解决方案

你的字节数组是零长度,这意味着它不够大保留任何字节,更不用说你检索的blob大小。你需要分配一个足够大的数组来保存blob,而不是传递零长度数组并希望最好!



见这里: Azure Blob存储第3部分:使用存储客户端库 - 简单对话 [ ^ ] - 代码在C#中,但在线转换将为您排序:代码转换器 [ ^

I want to download blob as byte array, but above mention error occur. my code is as follow



Dim fullFileBytes() As Byte = {}
Dim objAzureStorage As New AzureCloudStorage

                           Dim fullImageBlob As Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob = objAzureStorage.CloudContainer.GetBlockBlobReference(row(0))

                           fullImageBlob.DownloadToByteArray(fullFileBytes, 0)



What I have tried:

I have get stream of blob and convert it into byte.

解决方案

Your byte array is zero length, which means it isn't big enough to hold any bytes, much less whatever blob size you are retrieving. You need to allocate an array big enough to hold the blob, not pass a zero length array and hope for the best!

See here: Azure Blob Storage Part 3: Using the Storage Client Library - Simple Talk[^] - the code is in C#, but online convertes will sort that for you: Code Converter[^]


这篇关于Azure blob下载为字节数组错误“内存流不可扩展”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆