2017-02-11 99 views
0

Unity内のS3バケット間でファイルを転送しようとしていて、ドキュメントが見つからないような間違いのあるエラーが発生しています。両方のバケットは同じアカウントに属します。Unity内のAmazon S3バケット間でファイルを転送する

私はアセットを作成するたびに、それをDev BucketのS3サーバにアップロードします。これはうまくいきます。資産をコミットする準備ができたら、Prod Bucketから抜け出した資産のリストを調べて、Dev Bucketからそれらを転送する必要があります。私の研究から、IAmazonS3. CopyObjectAsync()はこの作業を行うべき機能です。 IAmazonS3.CopyObject()functionは、AmazonのUnity SDKで利用可能なではなく、です。私が知っている

Got Exception: 
Amazon.S3.AmazonS3Exception: Error making request with Error Code Moved and Http Status Code Moved. No further error information was returned by the service. Response Body: Encountered invalid redirect (missing Location header?) ---> Amazon.Runtime.Internal.HttpErrorResponseException: Exception of type 'Amazon.Runtime.Internal.HttpErrorResponseException' was thrown. 
at Amazon.Runtime.Internal.UnityRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
at Amazon.Runtime.Internal.HttpHandler`1[System.String].GetResponseCallbackHelper (System.Object state) [0x00000] in <filename unknown>:0 
--- End of inner exception stack trace --- 
at Amazon.Runtime.Internal.HttpErrorResponseExceptionHandler.HandleException (IExecutionContext executionContext, Amazon.Runtime.Internal.HttpErrorResponseException exception) [0x00000] in <filename unknown>:0 
at Amazon.Runtime.Internal.ExceptionHandler`1[T].Handle (IExecutionContext executionContext, System.Exception exception) [0x00000] in <filename unknown>:0 
at Amazon.Runtime.Internal.ErrorHandler.ProcessException (IExecutionContext executionContext, System.Exception exception) [0x00000] in <filename unknown>:0 
at Amazon.Runtime.Internal.ErrorHandler.InvokeAsyncCallback (IAsyncExecutionContext executionContext) [0x00000] in <filename unknown>:0 

:これはAmazon Error Code documentationで言及されていない「移動」のエラーコードになり

public void TestCopy() 
{ 
    var request = new CopyObjectRequest() 
    { 
     SourceBucket = mLoginData.DevBucket, 
     SourceKey = "myPic.jpg", 
     DestinationBucket = mLoginData.ProdBucket, 
     DestinationKey = "myPic.jpg" 
    }; 

    AWSConfigs.HttpClient = AWSConfigs.HttpClientOption.UnityWebRequest; 

    Client.CopyObjectAsync(request,(responseObj) => 
    { 
     if (responseObj.Exception == null) 
     { 
      ResultText.text += "Copied Object"; 
     } 
     else 
     { 
      ResultText.text += "Got Exception: \n" + responseObj.Exception.ToString(); 
     } 
    }); 
} 

:ここ

は、オブジェクトをコピーしようとしているときに、私は呼んコードですバケツの表示/リスト表示、両方のバケットへのファイルのアップロード/一覧表示/削除などが可能であるため、私は正しく設定されています。ソリューションはUnity Editorから実行することが重要です。

+0

これらの新しいバケットはありますか? –

+0

いいえ、これはすでに過去4ヶ月間使用されているものがたくさんあるバケットです –

答えて

0

CopyObjectAsyncは、ソース領域ではなく宛先領域で構成されたIAmazonS3クライアントのインスタンスを使用する必要があることが判明しました。これを変更するとコピーがうまくできました。

0

直接S3のAPIを扱う豊富な経験に基づいて、私はこれはあなたの誤りであることを合理的に確信しています:

PermanentRedirect

The bucket you are attempting to access must be addressed using the specified endpoint. Send all future requests to this endpoint.

301 Moved Permanently

私は基本的なライブラリは、あなたからこれを隠しているとMovedエラーがそのライブラリのであると信じて301エラーの解釈。なぜそれが理にかなっていないのですが、S3 REST APIを使って直接作業する方が好きです。

Encountered invalid redirect (missing Location header?) 

これは、文書化された動作と一致しています。

To help you find these errors during development, this type of redirect does not contain a Location HTTP header that allows you to automatically follow the request to the correct location. Consult the resulting XML error document for help using the correct Amazon S3 endpoint.

http://docs.aws.amazon.com/AmazonS3/latest/dev/Redirects.html

このXML応答本文に手を差し伸べる方法があれば、参考になるかもしれません。

グローバル(非リージョン固有)エンドポイントを使用してバケットにアクセスし、バケットがus-east-1以外の領域にある場合、このエラーはバケット作成の最初の数分で一般的です私はバケツが新しいかどうか尋ねました。

バケットがus-east-1に属していない場合、上記のエラーはリクエストが間違ったリージョナルエンドポイントに到着している可能性があるため、コードのどこかでリージョンを渡す必要があります。

+1

ソースバケットはUS-West-2にあり、バケットはUS-East-1にあります。私はちょうどこれを見つけただけで、あなたの結論に同意しているようです。地域のバケット間の転送方法を読みとるとともに、コピー機能で地域コードを渡してみましょう。方向をありがとう! –

関連する問題