I used aws sdk (https://github.com/aws/aws-sdk-php).
code
$result = $client->putObject(array(
'Bucket' => $bucket,
'Key' => $key,
'Body' => $file,
'ACL' => 'public-read',
));
It's work well but i have a question:
Thanks.
It is returned in the response. See the API docs for putObject.
$result = $client->putObject(array(
'Bucket' => $bucket,
'Key' => $key,
'Body' => $file,
'ACL' => 'public-read',
));
$url = $result['ObjectURL'];
You can also use the getObjectUrl()
method to get the URL.
$url = $client->getObjectUrl($bucket, $key);
The result returned is an instance of Guzzle\Service\Resource\Model.
To get the url just use the get method provided by that class.
$result = $client->putObject(array(
'Bucket' => $bucket,
'Key' => $key,
'Body' => $file,
'ACL' => 'public-read',
));
$url = $result->get('ObjectURL');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With