Object storage API for PHP application
Can any help me with API, how do I upload image to Object Storage from my backed server (PHP) and generate a public URL to access the image from client side?
Hi @iswap! There's more info on how to use our API to create an object URL here:
Hi @mjones, thanks for your reply. Using CLI or s3cmd I can upload images or files manually not from my server side code right. So if I want to upload image from client application like android/ios app how do I do that. These documentation is not clear enough.
Thanks for you reply. The following code is from you example. Is here Body contain the image file.
$result = $s3Client->putObject([
'Bucket' => $your_bucket_name,
'Key' => 'my-file-name',
'Body' => 'this is the body!'
Absolutely, Body is whatever you want the content of the file to hold.
It can be a simple string like in my example, in which case you end up with a simple text file, or it can be a resource handle.
So, for example, you might do:
... 'Body' => @fopen('/path/to/image.jpg', 'r') ...
The AWS documentation for the
PutObject method is available here.