diff --git a/classes/local/store/s3/client.php b/classes/local/store/s3/client.php index d9551f04..869438fb 100644 --- a/classes/local/store/s3/client.php +++ b/classes/local/store/s3/client.php @@ -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');