From 07238260ed04cd6b2a28684357caa9d935290194 Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Fri, 10 Jul 2015 10:27:28 -0400 Subject: [PATCH 1/6] Remove incorrect sql in 2.5.14 upgrade --- .../controllers/upgrade_sql/airtime_2.5.14/upgrade.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/airtime_mvc/application/controllers/upgrade_sql/airtime_2.5.14/upgrade.sql b/airtime_mvc/application/controllers/upgrade_sql/airtime_2.5.14/upgrade.sql index 3a5362ca1..218a74096 100644 --- a/airtime_mvc/application/controllers/upgrade_sql/airtime_2.5.14/upgrade.sql +++ b/airtime_mvc/application/controllers/upgrade_sql/airtime_2.5.14/upgrade.sql @@ -1,4 +1,3 @@ -ALTER TABLE cc_pref ALTER COLUMN subjid SET NULL; ALTER TABLE cc_pref ALTER COLUMN subjid SET DEFAULT NULL; CREATE UNIQUE INDEX cc_pref_key_idx ON cc_pref (keystr) WHERE subjid IS NULL; ANALYZE cc_pref; \ No newline at end of file From ffb55de566ce19bbbbdf9df17139e391bb9de834 Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Wed, 15 Jul 2015 13:12:56 -0400 Subject: [PATCH 2/6] SAAS-922 take 2 --- airtime_mvc/application/models/airtime/CcFiles.php | 14 +++++--------- airtime_mvc/application/services/MediaService.php | 1 + 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/airtime_mvc/application/models/airtime/CcFiles.php b/airtime_mvc/application/models/airtime/CcFiles.php index c574c9d7c..498276f2b 100644 --- a/airtime_mvc/application/models/airtime/CcFiles.php +++ b/airtime_mvc/application/models/airtime/CcFiles.php @@ -363,14 +363,6 @@ class CcFiles extends BaseCcFiles { unset($response[$key]); } - $mime = $file->getDbMime(); - if (!empty($mime)) { - // Get an extension based on the file's mime type and change the path to use this extension - $path = pathinfo($file->getDbFilepath()); - $ext = FileDataHelper::getFileExtensionFromMime($mime); - $response["filepath"] = ($path["dirname"] . '/' . $path["filename"] . $ext); - } - return $response; } @@ -385,8 +377,12 @@ class CcFiles extends BaseCcFiles { public function getFilename() { $info = pathinfo($this->getAbsoluteFilePath()); + //filename doesn't contain the extension because PHP is awful - return $info['filename'].".".$info['extension']; + $mime = $this->getDbMime(); + $extension = FileDataHelper::getFileExtensionFromMime($mime); + + return $info['filename'].".".$extension; } /** diff --git a/airtime_mvc/application/services/MediaService.php b/airtime_mvc/application/services/MediaService.php index 55eaeff37..807d6de17 100644 --- a/airtime_mvc/application/services/MediaService.php +++ b/airtime_mvc/application/services/MediaService.php @@ -62,6 +62,7 @@ class Application_Service_MediaService if ($media->getPropelOrm()->isValidPhysicalFile()) { $filename = $media->getPropelOrm()->getFilename(); + //Download user left clicks a track and selects Download. if (!$inline) { //We are using Content-Disposition to specify From 7ecabffbe893a6e00ac51bc8c395f3c17e60446d Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Wed, 15 Jul 2015 13:41:03 -0400 Subject: [PATCH 3/6] Avoid double dot in extension for SAAS-922 --- airtime_mvc/application/models/airtime/CcFiles.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/application/models/airtime/CcFiles.php b/airtime_mvc/application/models/airtime/CcFiles.php index 498276f2b..76fcf1d21 100644 --- a/airtime_mvc/application/models/airtime/CcFiles.php +++ b/airtime_mvc/application/models/airtime/CcFiles.php @@ -382,7 +382,7 @@ class CcFiles extends BaseCcFiles { $mime = $this->getDbMime(); $extension = FileDataHelper::getFileExtensionFromMime($mime); - return $info['filename'].".".$extension; + return $info['filename'] . $extension; } /** From 8276b1762eb8894c3bbf64669b117f52f2373972 Mon Sep 17 00:00:00 2001 From: drigato Date: Wed, 15 Jul 2015 13:47:54 -0400 Subject: [PATCH 4/6] Updated outdated public airtime api setting message on preferences page --- airtime_mvc/application/forms/GeneralPreferences.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/airtime_mvc/application/forms/GeneralPreferences.php b/airtime_mvc/application/forms/GeneralPreferences.php index 94230e667..be12ea565 100644 --- a/airtime_mvc/application/forms/GeneralPreferences.php +++ b/airtime_mvc/application/forms/GeneralPreferences.php @@ -107,8 +107,7 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm )); $third_party_api->setValue(Application_Model_Preference::GetAllow3rdPartyApi()); $third_party_api->setDescription(_('Enabling this feature will allow Airtime to provide schedule data - to external widgets that can be embedded in your website. Enable this - feature to reveal the embeddable code.')); + to external widgets that can be embedded in your website.')); $third_party_api->setSeparator(' '); //No
between radio buttons //$third_party_api->addDecorator(new Zend_Form_Decorator_Label(array('tag' => 'dd', 'class' => 'radio-inline-list'))); $third_party_api->addDecorator('HtmlTag', array('tag' => 'dd', From 064e1bd4e0d919904adc79ec832357fb25dab35e Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Wed, 15 Jul 2015 17:33:33 -0400 Subject: [PATCH 5/6] 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()); } /** From ffaa0767672343684d3405b61274323de7cdb75b Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Wed, 15 Jul 2015 17:51:37 -0400 Subject: [PATCH 6/6] 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; } /**