从 xamarin 应用程序上传到 blob 存储

问题描述

我有一个内置于 Xamarin 的移动应用程序。我有一个录制视频的功能,然后我需要将它上传到 Blob 存储。视频大小可能是 100 MB 或 200 MB。下面是代码

BlobServiceClient client = new BlobServiceClient("storageConnectionString");
BlobContainerClient containerClient = client.GetBlobContainerClient("ContainerName");
BlobClient blobClient = containerClient.GetBlobClient(fileName);
MemoryStream memoryStream = new MemoryStream("Array of bytes");
await containerClient.UploadBlobAsync("fileName",memoryStream);
memoryStream.Close();
memoryStream.dispose();

尝试上传大型视频(例如 60 MB 视频)时出现以下异常

Retry Failed after 6 tries. (The operation was canceled.) (The operation was canceled.) 
(The operation was canceled.) (The operation was canceled.) (The operation was canceled.) 
(The operation was canceled.)


at Azure.Core.Pipeline.RetryPolicy.ProcessAsync (Azure.Core.HttpMessage message,System.ReadOnlyMemory`1[T] pipeline,System.Boolean async) [0x001b8] in     
<bc1a25630f42495eb986d0b74fe4ff40>:0 
  at Azure.Core.Pipeline.HttpPipelinesynchronousPolicy.ProcessAsync (Azure.Core.HttpMessage message,System.ReadOnlyMemory`1[T] pipeline) [0x00086] in <bc1a25630f42495eb986d0b74fe4ff40>:0 
at Azure.Core.Pipeline.HttpPipelinesynchronousPolicy.ProcessAsync (Azure.Core.HttpMessage message,System.ReadOnlyMemory`1[T] pipeline) [0x00086] in <bc1a25630f42495eb986d0b74fe4ff40>:0 
at Azure.Storage.Blobs.BlobRestClient+BlockBlob.UploadAsync (Azure.Core.Pipeline.ClientDiagnostics 
clientDiagnostics,Azure.Core.Pipeline.HttpPipeline pipeline,System.Uri resourceUri,System.IO.Stream body,system.int64 contentLength,System.String version,System.Nullable`1[T] 
timeout,System.Byte[] transactionalContentHash,System.String blobContentType,System.String 
blobContentEncoding,System.String blobContentLanguage,System.Byte[] blobContentHash,System.String 
blobcacheControl,System.Collections.Generic.IDictionary`2[TKey,TValue] Metadata,System.String 
leaseId,System.String blobContentdisposition,System.String encryptionKey,System.String 
encryptionKeySha256,System.Nullable`1[T] encryptionAlgorithm,System.String encryptionScope,System.Nullable`1[T] tier,System.Nullable`1[T] ifModifiedSince,System.Nullable`1[T] 
ifUnmodifiedSince,System.Nullable`1[T] ifMatch,System.Nullable`1[T] ifNoneMatch,System.String 
ifTags,System.String requestId,System.String blobTagsstring,System.Boolean async,System.String 
operationName,System.Threading.CancellationToken cancellationToken) [0x001e2] in 
<306eef6cb8644c19b928e83686007d43>:0 
at System.Threading.Tasks.ValueTask`1[TResult].get_Result () [0x0001b] in 
/Users/builder/jenkins/workspace/archive-mono/2020- 
02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 
at Azure.Storage.Blobs.Specialized.BlockBlobClient.UploadInternal (System.IO.Stream content,Azure.Storage.Blobs.Models.BlobHttpHeaders blobHttpHeaders,TValue] tags,Azure.Storage.Blobs.Models.BlobRequestConditions conditions,System.Nullable`1[T] accesstier,System.IProgress`1[T] progressHandler,System.String operationName,System.Threading.CancellationToken cancellationToken) [0x00334] in 
<306eef6cb8644c19b928e83686007d43>:0 
at Azure.Storage.Blobs.Specialized.BlockBlobClient+<>c_displayClass54_0. 
<GetPartitionedUploaderBehaviors>b_0 (System.IO.Stream stream,Azure.Storage.Blobs.Models.BlobUploadOptions args,System.Threading.CancellationToken 
cancellationToken) [0x000c9] in <306eef6cb8644c19b928e83686007d43>:0 
at Azure.Storage.PartitionedUploader`2[TServiceSpecificArgs,TCompleteUploadReturn].UploadInternal 
(System.IO.Stream content,TServiceSpecificArgs args,System.Threading.CancellationToken cancellationToken) [0x001ce] in 
<306eef6cb8644c19b928e83686007d43>:0 
at Azure.Storage.Blobs.BlobClient.StagedUploadInternal (System.IO.Stream content,Azure.Storage.Blobs.Models.BlobUploadOptions options,System.Threading.CancellationToken cancellationToken) [0x001c5] in 
<306eef6cb8644c19b928e83686007d43>:0 
at Azure.Storage.Blobs.BlobContainerClient.UploadBlobAsync (System.String blobName,System.IO.Stream 
content,System.Threading.CancellationToken cancellationToken) [0x00083] in 
<306eef6cb8644c19b928e83686007d43>:0 

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)