0
0

More than 1 year has passed since last update.

AWS SDK for PHPでS3からgzipファイルをそのまま(展開されることなく)取得したい

Last updated at Posted at 2023-01-18

はじめに

PHPでaws-sdkを使用してS3からファイルをダウンロードする際に、gzipファイルが展開された状態で出力される場合があります。
特に、gzipのままファイルが欲しい場合に困ってしまいます。

対応

クライアント作成時に 'http' => ['decode_content' => false] を追加することで、gzipファイルが展開されずに(gzipファイルのまま)取得することができます。

require 'vendor/autoload.php';

use Aws\S3\S3Client;
use Aws\Exception\AwsException;

$s3 = new \Aws\S3\S3Client([
    'resion' => 'ap-northeast-1',
    'version' => 'latest',
    'profile' => 'default',
    'http' => ['decode_content' => false]
]);

参考

↓の decode_content を参照

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