简体   繁体   中英

php set s3 content-disposition as attachment

I want to set the content-disposition as attachment in a s3 bucket while

uploading file to S3 bucket ,below is my code im using.

$s3 = new S3(AWS_KEY, AWS_SECRET_KEY);

 if ($s3->putObjectFile("$uploadDir/$file", AWS_BUCKET, "$targetDir/$file", S3::ACL_PUBLIC_READ)) {
$syncSize = $s3->getObjectInfo(AWS_BUCKET, "$targetDir/$file");

}

Add contentDisposition in putobject in php as 'ContentDisposition' => 'attachment',

$result = $client->putObject(array(
  'Bucket'     => $bucket,
  'Key'        => $fileName,
  'SourceFile' => $fileTempName,
  'ContentDisposition' => 'attachment',
  'Metadata'   => array(
    'Foo' => 'abc',
    'Baz' => '123'
  )
 ));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM