Force-Download with php on Amazon S3

后端 未结 12 1929
予麋鹿
予麋鹿 2020-12-13 07:40

I am trying to use http://code.google.com/p/amazon-s3-php-class/ to force-dowload files from AWS S3. I have an mp3 that I want people to \"play\" or \"download.\" By default

12条回答
  •  臣服心动
    2020-12-13 08:12

    This is now possible by overwriting the S3 headers using signed requests.

    Request Parameters

    There are times when you want to override certain response header values in a GET response. For example, you might override the Content-Disposition response header value in your GET request.

    You can override values for a set of response headers using the query parameters listed in the following table.

    response-content-type - Sets the Content-Type header of the response response-content-disposition - Sets the Content-Disposition header of the response.

    Note

    You must sign the request, either using an Authorization header or a pre-signed URL, when using these parameters. They cannot be used with an unsigned (anonymous) request.

    So, you would set those headers to:

    response-content-disposition: attachment; filename=FILENAME.EXT
    response-content-type: application/octet-stream
    

    Found answer here: https://stackoverflow.com/a/5903710/922522

提交回复
热议问题