I cant figure how to upload an image in space with metadata image/jpeg. I tried everything and that’s is not working. File is always showing as “application/octet-stream” in space.
I did this :
$this->getClient()->upload($this->getBucket(), $fileName, $content, $privacy, [
‘Metadata’ => [‘contentType’ => ‘image/jpeg’]
]);
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Click below to sign up and get $100 of credit to try our products over 60 days!
This works for me, you may want ‘Source’ instead of ‘Body’ depending on its format:
$result = $s3_client->putObject( array( ‘Bucket’ => $bucket_name, ‘Key’ => $fileName, ‘Body’ => $content, ‘ACL’ => ‘public-read’, // or ‘private’, ‘public-read-write’, etc. ‘ContentType’ => ‘image/jpeg’ ));
I haven’t tried all s3 options, but here is the reference for putObject(): https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-s3-2006-03-01.html#putobject