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’]
]);
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.