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

强颜欢笑 提交于 2020-01-03 00:30:32

问题


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:


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.



来源:https://stackoverflow.com/questions/10190308/give-unique-download-link-for-my-users-for-files-hosted-on-amazon-s3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!