I port my code from AWS PHP SDK1 to SDK2 ( https://github.com/aws/aws-sdk-php ).
I have an image downloader. In my previous version, I would specify the Content-Type of my image like this:
$response = $this->s3->create_object(
$bucket,
$key,
array(
'fileUpload'=>$file_resource,
'contentType'=>$mime,
'acl' => AmazonS3::ACL_PUBLIC,
)
);
This is my new version:
$response = $this->s3->upload(
$bucket,
$key,
$file_resource,
'public-read',
array('params' => array('Metadata' => array('ContentType'=>$mime)))
);
I tried various spellings of ContentType, on the S3 website it changes the name to look like "x-amz-meta-contenttype", and the value of "Content-Type" is the default binary / octet stream.
I also tried using the EntityBody function, but the same results:
$response = $this->s3->upload(
$this->bucket,
$to,
EntityBody::factory($file_resource),
'public-read',
array('params' => array('Metadata' => array('ContentType'=>$mime)))
);
How to set content type in this new API?
EDIT: I see somewhere in the documentation:
AWS SDK PHP Content-Type, . , Content-Type , Content-Type, ContentType .
-, , , S3, "/ ". , "ContentType", , ...