0
私は(画像は私のReduxのdevのツールのスクリーンショットです) react-native-aws3でAWS S3に画像をアップロードするから戻って、この応答を取得してい

enter image description hereTemporaryRedirectエラーが反応するネイティブ

私が使用していますこのReduxの-観察大作:

name: "image-5a430850-8314-497e-8d56-0df45e3fed95.jpg" 
type: "image/png" 
uri: "file:///storage/sdcard/Android/data/com.vepo/files/Pictures/image-5a430850-8314-497e-8d56-0df45e3fed95.jpg" 

オプション:

export const uploadImageEpic = action$ => 
    action$.ofType(UPLOAD_IMAGE) 
    .mergeMap(action => 
     Observable.fromPromise(
     RNS3.put(action.payload.file, action.payload.options) 
    ) 
     .map(response => uploadImageFulfilled(response)) 
     .catch(error => { 
      return Observable.of(uploadImageRejected(error.xhr.response)) 
     }) 
    ) 

action.payload.fileこの(クロムコンソールからコピーされたオブジェクト)であります(クロムコンソールからコピーされたオブジェクト):

accessKey: "cant really give this away" 
bucket: "vepo-images" 
region: "ap-southeast-2" 
secretKey: "cant really give this away" 
successActionStatus: 201 

とにかく、もう一方のエンドポイントにもう一度お試しください。だから私はこれをオプションオブジェクトに追加しました:url: 'vepo-images.s3-ap-southeast-2.amazonaws.com'と私はAWSからまったく同じ応答を返しました。また、URLとしてs3-ap-southeast-2.amazonaws.comを試しました。

私はこれについて何をすべきでしょうか?

マイCORSバケットの設定:

<?xml version="1.0" encoding="UTF-8"?> 
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> 
<CORSRule> 
    <AllowedOrigin>*</AllowedOrigin> 
    <AllowedMethod>GET</AllowedMethod> 
    <AllowedMethod>PUT</AllowedMethod> 
    <AllowedMethod>POST</AllowedMethod> 
    <AllowedMethod>DELETE</AllowedMethod> 
    <MaxAgeSeconds>3000</MaxAgeSeconds> 
    <AllowedHeader>*</AllowedHeader> 
    <AllowedHeader>Authorization</AllowedHeader> 
</CORSRule> 
</CORSConfiguration> 

バケットポリシー:

{ 
    "Id": "Policy1495174705604", 
    "Version": "2012-10-17", 
    "Statement": [ 
    { 
     "Sid": "Stmt1495174695734", 
     "Action": "s3:*", 
     "Effect": "Allow", 
     "Resource": "arn:aws:s3:::vepo-images/*", 
     "Principal": "*" 
    } 
    ] 
} 

はEDIT:それは作られた変更なしで、動作するようになりました。どちらもoptionオブジェクトにurlが追加されず、url: 's3-ap-southeast-2.amazonaws.comが追加されていません。だから、AWS S3 APIは少し気になるかもしれませんが、それは問題になるかもしれません。私はちょうど307をキャッチして、optionsの内外でurlパラメータをトグルして再試行すると思います。

答えて

0

これまで使用していたHTTPクライアントをfollowRedirects = trueに設定する必要があります。

今は307、その後は302になる可能性があり、AWSが本当にナットした場合は301になります。

+0

ありがとう、私は[react-native-aws3](https://github.com/benjreinhart/react-native-aws3)を使用しているので、私はそれを行うことができないと思うので、httpクライアント。しかし、リダイレクト処理は良い機能要求である可能性があります。 – BeniaminoBaggins

関連する問題