user1115538
user1115538

Reputation:

Give Unique download link for my users for files hosted on Amazon S3

I have an Amazon S3 account in which I'm storing MP3 files. I play these files on a music player on my web app. I want the users to be able to download the songs from my site. How can I give them a temporary link to download the file? Do I need to give them the path to the file on AS3? I don't want the link to be shared with other people. How is it possible to do? P.S I'm building the app with PHP and the music player in SoundManager 2.

Upvotes: 1

Views: 955

Answers (1)

Geoff Appleford
Geoff Appleford

Reputation: 18832

You can create urls that expire at a specific time.

The easiest way to generate them would be to use the SDK for PHP and its get_object_url method.

// Instantiate the class
$s3 = new AmazonS3();

// Get the URL
$url = $s3->get_object_url('aws-php-sdk-test', 'mårkér wîth spåcés ånd întl/åéîøü.txt', '5 minutes', array(
    'response' => array(
        'content-type' => 'text/plain',
        'content-language' => 'en-US',
        'expires' => gmdate(DATE_RFC2822, strtotime('1 January 1980'))
    )
));

If you are new to S3 you need to spend some time going through Amazons online documentation.

Upvotes: 2

Related Questions