MKoosej
MKoosej

Reputation: 3696

Setting content-type meta data on s3 multi part upload

I'm trying to set the content-type meta data for the files I'm uploading using s3 api in php. My code looks like this:

 $upload_model = $s3->createMultipartUpload(array("Bucket" => $bucket , "Key"=> $key, "ACL"=>$acl , "Metadata" => array('Content-Type' => $this -> get_file_type($file_path) ) ) );

suppose I have "video/webm" content type, the result that I see in my s3 browser is that the "Content-Type" set to "binary/octet-stream" and s3 create a "x-amz-meta-content-type" for me with "video/wemb" value inside of it which is totally useless for my purpose. Because browsers only respond to "Content-Type" header to decide whether download the files or show them in the browser instead.

Upvotes: 4

Views: 6060

Answers (1)

MKoosej
MKoosej

Reputation: 3696

I find out the problem , It was kind of a misconception. the Content-Type meta data has its own parameter in createMultipartUpload function. so this piece of code worked just fine:

$s3->createMultipartUpload(array("Bucket" => $bucket , "Key"=> $key, "ACL"=>$acl , "ContentType" => $this -> get_file_type($file_path) ) );

I don't know about this but it seems any name you provide for the metadata s3 add an x-amz-meta prefix into it to indicate that it's a user defined meta data.

Upvotes: 6

Related Questions