Change original file name on boot?

I am using amazon S3 service with PHP using this API
   https://github.com/tpyo/amazon-s3-php-class
 I am passing the url to the client like this,

https://domain.s3.amazonaws.com/bucket/filename_11052011111924.zip?AWSAccessKeyId=myaccesskey&Expires=1305311393&Signature=mysignature

Therefore, when the client clicks or inserts the URL into the browser, the file is downloaded with the name filename_11052011111924.zip. But I saved my original file name in the database.

So is it possible to download when transferring one URL to the client and downloading with the original file name. I'm not sure if this will help me.

Content-Disposition: attachment; filename=FILENAME.EXT
Content-Type: application/octet-stream
+3
source share
3 answers

, ( , ). , , , ( cron) ().

.

+1

, S3, . ( S3 - . AWS)

, , AWS S3 SDK.

- ( php, ):

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

$response = $s3->create_object('bucket', 'filename_11052011111924.zip', array(
    'fileUpload' => 'filename.zip',
    'contentType' => 'application/octet-stream',
    'headers' => array( // raw headers
        'Content-Disposition' => 'attachment; filename=filename.zip',
    ),
));

, URL-. . http://docs.amazonwebservices.com/AWSSDKforPHP/latest/#m=AmazonS3/get_object_url

$url = $s3->get_object_url('bucket', 'filename_11052011111924.zip', '5 minutes', array(
    'response' => array(
          'Content-Disposition' => 'attachment; filename=filename.zip'
    )
));
+6

Yes, you can tell AWS how the output file should be specified:

Note: we encode the file name!

$filename = "Here we can have some utf8 chars.ext";
$outputFileName = '=?UTF-8?B?' . base64_encode($filename) . '?=';
$url = $s3->get_object_url(
   'bucket_name', 
   'path_to_the_file.ext', 
   '5 minutes', 
   array(
      'response' => array(
          'content-disposition' => 'attachment;' . " filename=\"" . $outputFileName . "\";")
      )
   )
);
0
source

All Articles