From 064e1bd4e0d919904adc79ec832357fb25dab35e Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Wed, 15 Jul 2015 17:33:33 -0400 Subject: [PATCH] Fix SAAS-922 for files on S3 too --- .../application/cloud_storage/Amazon_S3StorageBackend.php | 6 +++--- .../application/cloud_storage/FileStorageBackend.php | 2 +- .../application/cloud_storage/ProxyStorageBackend.php | 4 ++-- airtime_mvc/application/cloud_storage/StorageBackend.php | 2 +- airtime_mvc/application/models/airtime/CloudFile.php | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/airtime_mvc/application/cloud_storage/Amazon_S3StorageBackend.php b/airtime_mvc/application/cloud_storage/Amazon_S3StorageBackend.php index 270015ae0..15d76f1a7 100644 --- a/airtime_mvc/application/cloud_storage/Amazon_S3StorageBackend.php +++ b/airtime_mvc/application/cloud_storage/Amazon_S3StorageBackend.php @@ -42,12 +42,12 @@ class Amazon_S3StorageBackend extends StorageBackend } /** Returns a signed download URL from Amazon S3, expiring in 60 minutes */ - public function getDownloadURLs($resourceId) + public function getDownloadURLs($resourceId, $contentDispositionFilename) { $urls = array(); - $signedS3Url = $this->s3Client->getObjectUrl($this->getBucket(), $resourceId, '+60 minutes'); - + $s3args = array('response-content-disposition', "attachment; filename=" . urlencode($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 //been generated by the above. (The request signature must be for the amazonaws.com, diff --git a/airtime_mvc/application/cloud_storage/FileStorageBackend.php b/airtime_mvc/application/cloud_storage/FileStorageBackend.php index e7a87147e..1e111daf1 100644 --- a/airtime_mvc/application/cloud_storage/FileStorageBackend.php +++ b/airtime_mvc/application/cloud_storage/FileStorageBackend.php @@ -13,7 +13,7 @@ class FileStorageBackend extends StorageBackend return $resourceId; } - public function getDownloadURLs($resourceId) + public function getDownloadURLs($resourceId, $contentDispositionFilename) { return ""; } diff --git a/airtime_mvc/application/cloud_storage/ProxyStorageBackend.php b/airtime_mvc/application/cloud_storage/ProxyStorageBackend.php index d99c62eef..391d34ac3 100644 --- a/airtime_mvc/application/cloud_storage/ProxyStorageBackend.php +++ b/airtime_mvc/application/cloud_storage/ProxyStorageBackend.php @@ -38,9 +38,9 @@ class ProxyStorageBackend extends StorageBackend return $this->storageBackend->getAbsoluteFilePath($resourceId); } - public function getDownloadURLs($resourceId) + public function getDownloadURLs($resourceId, $contentDispositionFilename) { - return $this->storageBackend->getDownloadURLs($resourceId); + return $this->storageBackend->getDownloadURLs($resourceId, $contentDispositionFilename); } public function deletePhysicalFile($resourceId) diff --git a/airtime_mvc/application/cloud_storage/StorageBackend.php b/airtime_mvc/application/cloud_storage/StorageBackend.php index f0d58ba42..890611692 100644 --- a/airtime_mvc/application/cloud_storage/StorageBackend.php +++ b/airtime_mvc/application/cloud_storage/StorageBackend.php @@ -15,7 +15,7 @@ abstract class StorageBackend /** Returns the file object's signed URL. The URL must be signed since they * privately stored on the storage backend. */ - abstract public function getDownloadURLs($resourceId); + abstract public function getDownloadURLs($resourceId, $contentDispositionFilename); /** Deletes the file from the storage backend. */ abstract public function deletePhysicalFile($resourceId); diff --git a/airtime_mvc/application/models/airtime/CloudFile.php b/airtime_mvc/application/models/airtime/CloudFile.php index 3f0331ccc..cb07d3a36 100644 --- a/airtime_mvc/application/models/airtime/CloudFile.php +++ b/airtime_mvc/application/models/airtime/CloudFile.php @@ -32,7 +32,7 @@ class CloudFile extends BaseCloudFile if ($this->proxyStorageBackend == null) { $this->proxyStorageBackend = new ProxyStorageBackend($this->getStorageBackend()); } - return $this->proxyStorageBackend->getDownloadURLs($this->getResourceId()); + return $this->proxyStorageBackend->getDownloadURLs($this->getResourceId(), $this->getFilename()); } /**