From 69c0f5c5b738e9ffbb048af56e2611c56108dca6 Mon Sep 17 00:00:00 2001 From: Alexander Razumenko Date: Wed, 14 May 2014 10:41:14 +0300 Subject: [PATCH] Refactored file download --- .../base/api/ibm_connectionsFilesFileApi.php | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/SugarModules/modules/ibm_connectionsFiles/clients/base/api/ibm_connectionsFilesFileApi.php b/SugarModules/modules/ibm_connectionsFiles/clients/base/api/ibm_connectionsFilesFileApi.php index effde76..092418f 100644 --- a/SugarModules/modules/ibm_connectionsFiles/clients/base/api/ibm_connectionsFilesFileApi.php +++ b/SugarModules/modules/ibm_connectionsFiles/clients/base/api/ibm_connectionsFilesFileApi.php @@ -79,20 +79,17 @@ public function getFile($api, $args) $fileContent = $connectionsApi->downloadFile($id); - header("Pragma: public"); - header("Cache-Control: maxage=1, post-check=0, pre-check=0"); - header("Content-Type: {$bean->content_type}"); - header("Content-Disposition: attachment; filename=\"{$bean->name}\";"); - header("Content-Length: " . strlen($fileContent)); - header("X-Content-Type-Options: nosniff"); - header("Expires: 0"); - set_time_limit(0); - //ob_clean(); - ob_start(); - header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + 2592000)); - echo $fileContent; - @ob_end_flush(); - exit(); + $api->getResponse()->setType(RestResponse::RAW); + + $api->setHeader("Pragma", "public"); + $api->setHeader("Cache-Control", "maxage=1, post-check=0, pre-check=0"); + $api->setHeader("Content-Type", $bean->content_type); + $api->setHeader("Content-Disposition", "attachment; filename=\"{$bean->name}\";"); + $api->setHeader("Content-Length", strlen($fileContent)); + $api->setHeader("X-Content-Type-Options", "nosniff"); + $api->setHeader("Expires", 0); + + return $fileContent; }