uploading image/jpeg in space

June 4, 2018 1.4k views

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']

1 Answer

This works for me, you may want 'Source' instead of 'Body' depending on its format:

$result = $s3client->putObject( array(
'Bucket' => $bucket
'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():

Have another answer? Share your knowledge.