Skip to content

Commit

Permalink
S3 pre-signed URL: error with unicode filename catalyst#455
Browse files Browse the repository at this point in the history
  • Loading branch information
PhucNguyen0311 committed Dec 20, 2021
1 parent 35951fd commit 755396d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion classes/local/store/s3/client.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,18 @@ private function generate_presigned_url_s3($contenthash, $headers) {

$contentdisposition = manager::get_header($headers, 'Content-Disposition');
if ($contentdisposition !== '') {
$params['ResponseContentDisposition'] = $contentdisposition;
$fparts = explode('; ', $contentdisposition);
if (!empty($fparts[1])) {
$originalfilename = str_replace('filename=', '', $fparts[1]); // Get the actual filename.
$originalfilename = str_replace('"', '', $originalfilename); // Remove the quotes.
}
if (!empty($fparts[0])) {
$contentdisposition = $fparts[0];
}
if (!empty($originalfilename)) {
$newcontentdisposition = $contentdisposition . '; ' . 'filename="' . utf8_encode($originalfilename) . '"';
$params['ResponseContentDisposition'] = $newcontentdisposition;
}
}

$contenttype = manager::get_header($headers, 'Content-Type');
Expand Down

0 comments on commit 755396d

Please sign in to comment.