Object storage API for PHP application

Hello,
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?

Thanks

5 Replies

Hi @iswap! There's more info on how to use our API to create an object URL here:

https://developers.linode.com/api/v4/object-storage-buckets-cluster-id-bucket-object-url/#post

However, I'd recommend using using our CLI or s3cmd instead if you're only wanting to upload things from the command line. Uploading things with them is a lot more straightforward as well.

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.

Hi @iswap

There is an official SDK for S3 written in PHP, which works just fine with Linode Object Storage.

Please see my answers on this community thread which includes a code sample.

Hi @andysh
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!'
]);

@iswap

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.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct