amazon web services - How to add ContentType to AWS PHP SDK MultiPartUploader -


i have searched high , low how add simple contenttype metadata multipartuploader in aws php sdk. docs mention how putobject, have no mention of how multipartuploader.

i have tried every method find online, nothing working , file getting set application/octet-stream.

does have experience this? here code:

$uploader = new multipartuploader($this->s3, $local_path, [     'bucket'      => env('aws_bucket'),     'key'         => $path .'/'. $filename,     'contenttype' => 'video/mp4',  //  have tried     'metadata'    => [             //  have tried (all variations of caps)         'contenttype' => 'video/mp4',     ] ]);   {     try      {         $result = $uploader->upload();     }      catch (multipartuploadexception $e)      {         $uploader = new multipartuploader($this->s3, $local_path, [             'state' => $e->getstate(),         ]);     } }  while (!isset($result)); 

after reading through multipartuploader class, looks contenttype should automatically set, not being set.

i using v3 of sdk

any advice appreciated!

i figured out right after posted question! post answer if else hits problem, can here.

the page linked in question has answer, not related contenttype!

here working code:

$uploader = new \aws\s3\multipartuploader($this->s3, $local_path, [     'bucket'      => env('aws_bucket'),     'key'         => $path .'/'. $filename,     'before_initiate' => function(\aws\command $command) use ($mime_type)  //  here relevant code     {         $command['contenttype'] = $mime_type;  //  video/mp4     } ]);   {     try      {         $result = $uploader->upload();     }      catch (\aws\exception\multipartuploadexception $e)      {         $uploader = new \aws\s3\multipartuploader($this->s3, $local_path, [             'state' => $e->getstate(),         ]);     } }  while (!isset($result));  return $result ? $result['objecturl'] : null; 

i hope helps else in future!


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -