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');
The object URL is available in the $result
variable that is returned in your function call.
To access the object URL do this:
$result = $client->putObject(array(
'Bucket' => $bucket,
'Key' => $key,
'Body' => $file,
'ACL' => 'public-read',
));
$data=$result->toArray();
$object_url=$data['ObjectURL'];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.