by
8,624 33
0
5
321k
0
Top 1% !
Popular
Pearl of Wisdom
Specified
OpenSource
Popularity: 3250th place
Created
Modified Jul 23, 2013

Published on:

No tags for this snippet yet.
Extension.php
LanguagePHP
LicenseMIT_X11
Target Frameworkaws

Amazon AWS - PHP: Generate signed expiring download URL

This snippet demonstrates how to generate a download URL for a file stored in your S3 Bucket.
This will work for all files, even ACL private files. Download URL will be active for the specified time.
In order to use this service you must enable Amazon Simple Storage Service (Amazon S3) in your account.
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/5856/Amazon-AWS---PHP--Generate-signed-expiri?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
<?php require_once('sdk.class.php'); $s3 = new AmazonS3(); $fileName = 'test1.txt'; $bucketName = 'myBucketName'; $url = $s3->get_object_url($bucketName, $fileName, '1 hour'); echo("Download url: <a href=\"$url\">$url</a>\n"); ?>
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus