Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set custom Metadata on Amazon PHP SDK

I tried:

$objS3->putObject(array(
    'Bucket'     => $sBucket
    'Key'        => $sBucketFolder . $sFilenameToSave,
    'SourceFile' => $sFile,
    'ACL'        => 'public-read'
    'Metadata'   => [
        'Content-Type'      => 'text/css',
        'Content-Encoding'  => 'gzip', 
    ]
));

But it did not work. Any idea?

Tks.

like image 571
Kennedy Avatar asked Feb 06 '26 21:02

Kennedy


1 Answers

ContentType and ContentEncoding should not be sent as metadata. Use this instead:

$objS3->putObject(array(
    'Bucket'          => $sBucket
    'Key'             => $sBucketFolder . $sFilenameToSave,
    'SourceFile'      => $sFile,
    'ACL'             => 'public-read',
    'ContentType'     => 'text/css',
    'ContentEncoding' => 'gzip'
));
like image 146
dcro Avatar answered Feb 08 '26 12:02

dcro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!