Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Azure SDK PutBlockAsync引发错误:响应过早结束_C#_Azure_Azure Sdk .net - Fatal编程技术网

C# Azure SDK PutBlockAsync引发错误:响应过早结束

C# Azure SDK PutBlockAsync引发错误:响应过早结束,c#,azure,azure-sdk-.net,C#,Azure,Azure Sdk .net,我们正在尝试使用Azure SDK的PutBlockAsync API将文件上载到Azure Blob存储 using (var blockStream = new MemoryStream(block)) { await blob.PutBlockAsync(blockId, blockStream, "").ContinueWith((t) => { if (t.IsFaulted) {

我们正在尝试使用Azure SDK的PutBlockAsync API将文件上载到Azure Blob存储

   using (var blockStream = new MemoryStream(block))
   {
       await blob.PutBlockAsync(blockId, blockStream, "").ContinueWith((t) => {
             if (t.IsFaulted)
             {
                SysLog.Debug($"Error occured in PutBlockAsync while uploading a block for {blob.Name}. Please check error log.");
                SysLog.Error(t.Exception);
             }
             else if (t.IsCanceled)
             {
                SysLog.Debug($"PutBlockAsync cancelled for {blob.Name}.");
             }
             else
             {                                    
                isChunkSent = true;
             }  
          });
  }
上载失败,出现“响应提前结束”和以下错误/跟踪:

 ---> Microsoft.Azure.Storage.StorageException: An error occurred while sending the request.
 ---> System.Net.Http.HttpRequestException: An error occurred while sending the request.
 ---> System.IO.IOException: The response ended prematurely.
   at System.Net.Http.HttpConnection.FillAsync()
   at System.Net.Http.HttpConnection.ReadNextResponseHeaderLineAsync(Boolean foldedHeadersAllowed)
   at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.SendWithNtConnectionAuthAsync(HttpConnection connection, HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
   at Microsoft.Azure.Storage.Core.Executor.Executor.ExecuteAsync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext, CancellationToken token)
   --- End of inner exception stack trace ---
   at Microsoft.Azure.Storage.Core.Executor.Executor.ExecuteAsync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext, CancellationToken token)
   at Microsoft.Azure.Storage.Blob.CloudBlockBlob.PutBlockAsync(String blockId, Stream blockData, Checksum contentChecksum, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AggregatingProgressIncrementer progressIncrementer, CancellationToken cancellationToken)

非常感谢您的帮助。

@BrettCaswell感谢您的回复。我已经在原始版本中添加了代码post@BrettCaswell谢谢你的回复。我在原始帖子中添加了代码