Reputation: 10089
I'm using amazon S3 php to upload and download files.
for exemple to get a private file from amazon s3 I'm using:
// Cast the body to a primitive string
$bodyAsString = (string) $object['Body'];
and
public function getResponse($content, $filename, $length, $contentType)
{
$response = new Response();
$response->headers->set('Content-Description','File Transfer');
$response->headers->set('Content-Type',$contentType);
$response->headers->set('Content-Disposition','attachment; filename='.basename($filename));
$response->headers->set('Content-Transfer-Encoding','binary');
$response->headers->set('Expires','0');
$response->headers->set('Cache-Control','must-revalidate');
$response->headers->set('Pragma','public');
$response->headers->set('Content-Length',$length);
$response->setContent($content);
return $response;
}
TO download it
but this is very heavy for the server, is there a solution to directly download private objects from amazon s3 using a link, a little like for public objects with a security.
Upvotes: 0
Views: 2169
Reputation: 6527
You can create pre-signed URLs for objects that have an expiration date. You can use this feature to allow people to download private objects directly from Amazon S3. The AWS SDK for PHP has an easy S3Client::getObjectUrl()
method that can help you do this.
Upvotes: 1