0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

java_sdkでec2からs3へのファイルのやりとりができない(403エラー)場合は署名タイプバージョンを変えてみるとうまくいくかもしれない

Last updated at Posted at 2015-10-21

ローカル環境ではs3へのファイルのやり取りができていたのに、ec2にデプロイして実行するとs3とのやり取りで403エラーとなる。credentialの問題でもないならば署名タイプを疑ってみてもいいかも。

とりあえず、明示的にversion4を指定してあげればおkだと思います。

public void setup() {
    s3 = new AmazonS3Client();
    System.setProperty(SDKGlobalConfiguration.ENABLE_S3_SIGV4_SYSTEM_PROPERTY, "true"); // これ!!
    Region region = Region.getRegion(Regions.AP_NORTHEAST_1);
    s3.setRegion(region);
    s3.setEndpoint(endpoint);
}

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?