LoginSignup
5
5

More than 5 years have passed since last update.

S3のファイルをコピーしてそのまま公開

Last updated at Posted at 2015-09-26

画像ファイルを別バケットにコピーしたが、URLを叩いてもAccess Deniedになっていた.
そのまま公開させたい場合コピー時に権限設定が出来たのでメモ.

AWS SDK for PHP ver.2を使用


$s3 = Aws::factory([
            'key' => S3_ACCESS_KEY,
            'secret' => S3_SECRET_KEY,
            'region' => S3_REGION,
        ])->get('s3');

        $s3->copyObject([
            'Bucket' => $from_bucket,
            'Key' => "path/to/$file_name",
            'CopySource' => "$to_bucket/path/to/$file_name",
            'ACL' => 'public-read',   <- この権限設定を追加
        ]);
5
5
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
5
5