亚马逊:Amazon.S3.AmazonS3Exception使用Xamarin上传图片

时间:2015-11-05 18:03:53

标签: c# amazon-s3 xamarin amazon

我们在我支持的项目(实验室版本)上使用旧版SDK for Amazon A3。现在我想更新来自亚马逊的所有SDK并使用Cognito进行身份验证,而不是像以前那样直接传递凭据。

我的应用程序在Xamarin android上运行,需要将照片上传到Amazon S3。

使用我从Xamarin Studio上的NuGet包库获得的AWSSDK,我的代码创建了AmazonS3Client:

var credentials = new CognitoAWSCredentials("my pool id", Amazon.RegionEndpoint.UEast1);

var config = new AmazonS3Config() { RegionEndpoint = Amazon.RegionEndpoint.USWest2, Timeout = TimeSpan.FromSeconds(30) };

this.s3Client = new AmazonS3Client(credentials, config);

使用S3客户端上传图片的代码:

var request = new PutObjectRequest();
request.AutoCloseStream = true;
request.BucketName = this.bucket;
request.FilePath = filePath;
request.Key = key;
request.ContentType = "image/jpg";

if (handler != null) 
{
    request.StreamTransferProgress += (object sender, Amazon.Runtime.StreamTransferProgressArgs e) =>
    {
        handler(e, pedidoLacre, key, fotoPlaca);
    };
}

var taskResponse = this.s3Client.PutObjectAsync(request);
Task.WaitAll(taskResponse);

if (taskResponse.Exception != null)
{
    throw taskResponse.Exception;
}

异常错误:

System.AggregateException: One or more errors occurred. ---> Amazon.S3.AmazonS3Exception: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint. ---> Amazon.Runtime.Internal.HttpErrorResponseException: Exception of type 'Amazon.Runtime.Internal.HttpErrorResponseException' was thrown.
  at Amazon.Runtime.Internal.RedirectHandler.HandleRedirect (IExecutionContext executionContext) [0x00016] in d:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\HttpHandler\_mobile\HttpRequestMessageFactory.cs:183 
  at Amazon.Runtime.Internal.RedirectHandler+<InvokeAsync>d__0`1[Amazon.S3.Model.PutObjectResponse].MoveNext () [0x0004b] in d:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\HttpHandler\_mobile\HttpRequestMessageFactory.cs:261 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[Amazon.S3.Model.PutObjectResponse].GetResult () [0x00000] in <filename unknown>:0 
  at Amazon.Runtime.Internal.Unmarshaller+<InvokeAsync>d__0`1[Amazon.S3.Model.PutObjectResponse].MoveNext () [0x0005f] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[Amazon.S3.Model.PutObjectResponse].GetResult () [0x00000] in <filename unknown>:0 
  at Amazon.S3.Internal.AmazonS3ResponseHandler+<InvokeAsync>d__0`1[Amazon.S3.Model.PutObjectResponse].MoveNext () [0x0000d] in d:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Services\S3\Custom\Internal\AmazonS3ResponseHandler.cs:58 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[Amazon.S3.Model.PutObjectResponse].GetResult () [0x00000] in <filename unknown>:0 
  at Amazon.Runtime.Internal.ErrorHandler+<InvokeAsync>d__1`1[Amazon.S3.Model.PutObjectResponse].MoveNext () [0x00077] in d:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\Marshaller.cs:85 
  --- End of inner exception stack trace ---
  at Amazon.Runtime.Internal.HttpErrorResponseExceptionHandler.HandleException (IExecutionContext executionContext, Amazon.Runtime.Internal.HttpErrorResponseException exception) [0x00064] in d:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\RedirectHandler.cs:150 
  at Amazon.Runtime.Internal.ExceptionHandler`1[Amazon.Runtime.Internal.HttpErrorResponseException].Handle (IExecutionContext executionContext, System.Exception exception) [0x00007] in d:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\RedirectHandler.cs:41 
  at Amazon.Runtime.Internal.ErrorHandler.ProcessException (IExecutionContext executionContext, System.Exception exception) [0x0000d] in d:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\Marshaller.cs:38 
  at Amazon.Runtime.Internal.ErrorHandler+<InvokeAsync>d__1`1[Amazon.S3.Model.PutObjectResponse].MoveNext () [0x000b4] in d:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\Marshaller.cs:88 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[Amazon.S3.Model.PutObjectResponse].GetResult () [0x00000] in <filename unknown>:0 
  at Amazon.Runtime.Internal.CallbackHandler+<InvokeAsync>d__0`1[Amazon.S3.Model.PutObjectResponse].MoveNext () [0x00066] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[Amazon.S3.Model.PutObjectResponse].GetResult () [0x00000] in <filename unknown>:0 
  at Amazon.Runtime.Internal.CredentialsRetriever+<InvokeAsync>d__0`1[Amazon.S3.Model.PutObjectResponse].MoveNext () [0x000d5] in d:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\HttpHandler\HttpHandler.cs:357 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[Amazon.S3.Model.PutObjectResponse].GetResult () [0x00000] in <filename unknown>:0 
  at Amazon.Runtime.Internal.RetryHandler+<InvokeAsync>d__0`1[Amazon.S3.Model.PutObjectResponse].MoveNext () [0x0003f] in d:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Core\Amazon.Util\AWSSDKUtils.cs:572 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[Amazon.S3.Model.PutObjectResponse].GetResult () [0x00000] in <filename unknown>:0 
  at Amazon.Runtime.Internal.CallbackHandler+<InvokeAsync>d__0`1[Amazon.S3.Model.PutObjectResponse].MoveNext () [0x00066] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[Amazon.S3.Model.PutObjectResponse].GetResult () [0x00000] in <filename unknown>:0 
  at Amazon.Runtime.Internal.CallbackHandler+<InvokeAsync>d__0`1[Amazon.S3.Model.PutObjectResponse].MoveNext () [0x00066] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[Amazon.S3.Model.PutObjectResponse].GetResult () [0x00000] in <filename unknown>:0 
  at Amazon.S3.Internal.AmazonS3ExceptionHandler+<InvokeAsync>d__0`1[Amazon.S3.Model.PutObjectResponse].MoveNext () [0x0001c] in d:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Services\S3\Custom\Internal\AmazonS3ExceptionHandler.cs:57 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[Amazon.S3.Model.PutObjectResponse].GetResult () [0x00000] in <filename unknown>:0 
  at Amazon.Runtime.Internal.ErrorCallbackHandler+<InvokeAsync>d__0`1[Amazon.S3.Model.PutObjectResponse].MoveNext () [0x00064] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[Amazon.S3.Model.PutObjectResponse].GetResult () [0x00000] in <filename unknown>:0 
  at Amazon.Runtime.Internal.MetricsHandler+<InvokeAsync>d__0`1[Amazon.S3.Model.PutObjectResponse].MoveNext () [0x00011] in d:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\HttpHandler\_mobile\HttpRequestMessageFactory.cs:130 
  --- End of inner exception stack trace ---
  at System.Threading.Tasks.Task.WaitAll (System.Threading.Tasks.Task[] tasks, Int32 millisecondsTimeout, CancellationToken cancellationToken) [0x00242] in <filename unknown>:0 
  at System.Threading.Tasks.Task.WaitAll (System.Threading.Tasks.Task[] tasks, Int32 millisecondsTimeout) [0x00000] in <filename unknown>:0 
  at System.Threading.Tasks.Task.WaitAll (System.Threading.Tasks.Task[] tasks) [0x00000] in <filename unknown>:0 
  at LacreDigital.Shared.S3.LacreS3.Upload (System.String filePath, System.String key, LacreDigital.Shared.Data.PedidoLacre pedidoLacre, FotoPlaca fotoPlaca, LacreDigital.Shared.S3.HandleUploadProgressEvent handler) [0x00065] in d:\Projetos\LacreMobile\Mobile\branches\_10899\LacreDigital.Shared\Code\S3\LacreS3.cs:69 
---> (Inner Exception #0) Amazon.S3.AmazonS3Exception: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint. ---> Amazon.Runtime.Internal.HttpErrorResponseException: Exception of type 'Amazon.Runtime.Internal.HttpErrorResponseException' was thrown.
  at Amazon.Runtime.Internal.RedirectHandler.HandleRedirect (IExecutionContext executionContext) [0x00016] in d:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\HttpHandler\_mobile\HttpRequestMessageFactory.cs:183 
  at Amazon.Runtime.Internal.RedirectHandler+<InvokeAsync>d__0`1[Amazon.S3.Model.PutObjectResponse].MoveNext () [0x0004b] in d:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\HttpHandler\_mobile\HttpRequestMessageFactory.cs:261 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[Amazon.S3.Model.PutObjectResponse].GetResult () [0x00000] in <filename unknown>:0 
  at Amazon.Runtime.Internal.Unmarshaller+<InvokeAsync>d__0`1[Amazon.S3.Model.PutObjectResponse].MoveNext () [0x0005f] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[Amazon.S3.Model.PutObjectResponse].GetResult () [0x00000] in <filename unknown>:0 
  at Amazon.S3.Internal.AmazonS3ResponseHandler+<InvokeAsync>d__0`1[Amazon.S3.Model.PutObjectResponse].MoveNext () [0x0000d] in d:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Services\S3\Custom\Internal\AmazonS3ResponseHandler.cs:58 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[Amazon.S3.Model.PutObjectResponse].GetResult () [0x00000] in <filename unknown>:0 
  at Amazon.Runtime.Internal.ErrorHandler+<InvokeAsync>d__1`1[Amazon.S3.Model.PutObjectResponse].MoveNext () [0x00077] in d:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\Marshaller.cs:85 
  --- End of inner exception stack trace ---
  at Amazon.Runtime.Internal.HttpErrorResponseExceptionHandler.HandleException (IExecutionContext executionContext, Amazon.Runtime.Internal.HttpErrorResponseException exception) [0x00064] in d:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\RedirectHandler.cs:150 
  at Amazon.Runtime.Internal.ExceptionHandler`1[Amazon.Runtime.Internal.HttpErrorResponseException].Handle (IExecutionContext executionContext, System.Exception exception) [0x00007] in d:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\RedirectHandler.cs:41 
  at Amazon.Runtime.Internal.ErrorHandler.ProcessException (IExecutionContext executionContext, System.Exception exception) [0x0000d] in d:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\Marshaller.cs:38 
  at Amazon.Runtime.Internal.ErrorHandler+<InvokeAsync>d__1`1[Amazon.S3.Model.PutObjectResponse].MoveNext () [0x000b4] in d:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\Marshaller.cs:88 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[Amazon.S3.Model.PutObjectResponse].GetResult () [0x00000] in <filename unknown>:0 
  at Amazon.Runtime.Internal.CallbackHandler+<InvokeAsync>d__0`1[Amazon.S3.Model.PutObjectResponse].MoveNext () [0x00066] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[Amazon.S3.Model.PutObjectResponse].GetResult () [0x00000] in <filename unknown>:0 
  at Amazon.Runtime.Internal.CredentialsRetriever+<InvokeAsync>d__0`1[Amazon.S3.Model.PutObjectResponse].MoveNext () [0x000d5] in d:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\HttpHandler\HttpHandler.cs:357 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[Amazon.S3.Model.PutObjectResponse].GetResult () [0x00000] in <filename unknown>:0 
  at Amazon.Runtime.Internal.RetryHandler+<InvokeAsync>d__0`1[Amazon.S3.Model.PutObjectResponse].MoveNext () [0x0003f] in d:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Core\Amazon.Util\AWSSDKUtils.cs:572 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[Amazon.S3.Model.PutObjectResponse].GetResult () [0x00000] in <filename unknown>:0 
  at Amazon.Runtime.Internal.CallbackHandler+<InvokeAsync>d__0`1[Amazon.S3.Model.PutObjectResponse].MoveNext () [0x00066] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[Amazon.S3.Model.PutObjectResponse].GetResult () [0x00000] in <filename unknown>:0 
  at Amazon.Runtime.Internal.CallbackHandler+<InvokeAsync>d__0`1[Amazon.S3.Model.PutObjectResponse].MoveNext () [0x00066] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[Amazon.S3.Model.PutObjectResponse].GetResult () [0x00000] in <filename unknown>:0 
  at Amazon.S3.Internal.AmazonS3ExceptionHandler+<InvokeAsync>d__0`1[Amazon.S3.Model.PutObjectResponse].MoveNext () [0x0001c] in d:\Jenkins\jobs\v3-stage-release\workspace\AWSDotNetPublic\sdk\src\Services\S3\Custom\Internal\AmazonS3ExceptionHandler.cs:57 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[Amazon.S3.Model.PutObjectResponse].GetResult () [0x00000] in <filename unknown>:0 
  at Amazon.Runtime.Internal.ErrorCallbackHandler+<InvokeAsync>d__0`1[Amazon.S3.Model.PutObjectResponse].MoveNext () [0x00064] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <filename unknown>:0 

我们认为这里的重要细节是我们的S3桶位于US-WEST-2区域,而Cognito位于US-EAST-1。我们读到它并且它应该不是问题,但你永远不会知道。

修改 我们放弃了区域错误的可能性,因为我们在与S3客户端相同的区域上创建了一个新存储桶,并且Exception仍然存在。

1 个答案:

答案 0 :(得分:0)

前一段时间,我找到了解决这个问题的方法。

我的解决方案是使用代码创建存储桶。

var response = this.s3Client.PutBucketAsync("example");

在Amazon S3中使用sdk for xamarin是一个问题。