From ffaa0767672343684d3405b61274323de7cdb75b Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Wed, 15 Jul 2015 17:51:37 -0400 Subject: [PATCH] Second fix for SAAS-922, file extension improvements for S3 --- .../cloud_storage/Amazon_S3StorageBackend.php | 2 +- airtime_mvc/application/models/airtime/CloudFile.php | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/cloud_storage/Amazon_S3StorageBackend.php b/airtime_mvc/application/cloud_storage/Amazon_S3StorageBackend.php index 15d76f1a7..0d86ef52c 100644 --- a/airtime_mvc/application/cloud_storage/Amazon_S3StorageBackend.php +++ b/airtime_mvc/application/cloud_storage/Amazon_S3StorageBackend.php @@ -46,7 +46,7 @@ class Amazon_S3StorageBackend extends StorageBackend { $urls = array(); - $s3args = array('response-content-disposition', "attachment; filename=" . urlencode($contentDispositionFilename)); + $s3args = array('ResponseContentDisposition' => 'attachment; filename="' . $contentDispositionFilename. '"'); $signedS3Url = $this->s3Client->getObjectUrl($this->getBucket(), $resourceId, '+60 minutes', $s3args); //If we're using the proxy cache, we need to modify the request URL after it has diff --git a/airtime_mvc/application/models/airtime/CloudFile.php b/airtime_mvc/application/models/airtime/CloudFile.php index cb07d3a36..56390e28c 100644 --- a/airtime_mvc/application/models/airtime/CloudFile.php +++ b/airtime_mvc/application/models/airtime/CloudFile.php @@ -49,7 +49,14 @@ class CloudFile extends BaseCloudFile public function getFilename() { - return $this->getDbFilepath(); + $filename = $this->getDbFilepath(); + $info = pathinfo($filename); + + //Add the correct file extension based on the MIME type, for files that were uploaded with the wrong extension. + $mime = $this->getDbMime(); + $extension = FileDataHelper::getFileExtensionFromMime($mime); + + return $info['filename'] . $extension; } /**