将Azure Blob阻止上传限制从32 MB增加 [英] Increase Azure blob block upload limit from 32 MB
问题描述
我正在尝试将内容上传到azure blob,并且大小超过32MB.下面的C#代码段:
I am trying to upload a contents to azure blob and the size is over 32MB. The c# code snippet below:
CloudBlockBlob blob = _blobContainer.GetBlockBlobReference(blobName);
blob.UploadFromByteArray(contents, 0, contents.Length, AccessCondition.GenerateIfNotExistsCondition(), options:writeOptions);
每次blob超过32MB时,以上都会引发异常:
Everytime the blob is over 32MB, the above raises an exception:
Exception thrown: 'Microsoft.WindowsAzure.Storage.StorageException' in Microsoft.WindowsAzure.Storage.dll
Additional information: The remote server returned an error: (404) Not Found.
按照此
当块Blob上传大于此属性中的值时, 存储客户端将文件分成块.
When a block blob upload is larger than the value in this property, storage clients break the file into blocks.
是否应该有单独的代码行来启用此功能.
Should there be a separate line of code to enable this.
推荐答案
存储客户端默认最大32 MB的单个块上传.当块Blob上传大于
SingleBlobUploadThresholdInBytes
属性中的值时,存储客户端会将文件分成块.
Storage clients default to a 32 MB maximum single block upload. When a block blob upload is larger than the value in
SingleBlobUploadThresholdInBytes
property, storage clients break the file into blocks.
正如Tamra所说,存储客户端负责将文件拆分为块的工作.这是我的测试,目的是让您对它有更好的了解.
As Tamra said, the storage client handles the work of breaking the file into blocks. Here is my tests for you to have a better understanding of it.
代码示例
CloudBlockBlob blob = container.GetBlockBlobReference(blobName);
var writeOptions = new BlobRequestOptions()
{
SingleBlobUploadThresholdInBytes = 50 * 1024 * 1024, //maximum for 64MB,32MB by default
};
blob.UploadFromByteArray(contents, 0, contents.Length, AccessCondition.GenerateIfNotExistsCondition(), options: writeOptions);
场景
-
如果编写的块Blob大小不超过
SingleBlobUploadThresholdInBytes
属性,则可以通过一次写入操作将其完整上传.
If you are writing a block blob that is no more than the
SingleBlobUploadThresholdInBytes
property in size, you could upload it in its entirety with a single write operation.
您可以通过在调用UploadFromByteArray
方法时通过Fiddler捕获网络包来理解它.
You could understand it by capturing the Network Package via Fiddler when you invoke the UploadFromByteArray
method.
当块Blob上传的大小大于SingleBlobUploadThresholdInBytes
属性中的值时,存储客户端会自动将文件拆分为块.
When a block blob upload is larger than the value in SingleBlobUploadThresholdInBytes
property in size, storage clients break the file into blocks automatically.
我上传了一个大小将近90MB的Blob,然后您会发现以下差异:
I upload a blob which size is nearly 90MB, then you could find the difference as follows:
在快照上,您会发现存储客户端将文件分成大小为4MB的块并同时上载这些块.
Upon the snapshot, you could find that storage clients break the file into blocks with 4MB in size and upload the blocks simultaneously.
每次blob超过32MB时,以上内容都会引发异常
Every time the blob is over 32MB, the above raises an exception
当您调用UploadFromByteArray
方法以查找详细错误时,可以尝试设置SingleBlobUploadThresholdInBytes
属性或捕获网络包.
You could try to set the SingleBlobUploadThresholdInBytes
property or capture the Network Package when you invoke the UploadFromByteArray
method to find the detailed error.
这篇关于将Azure Blob阻止上传限制从32 MB增加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!