Give Unique download link for my users for files h

2019-05-29 23:01发布

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.

1条回答
劳资没心,怎么记你
2楼-- · 2019-05-29 23:29

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.

查看更多
登录 后发表回答