Skip to content

Commit

Permalink
Merge pull request sugarcrm#23 from arazumenko-sugarcrm/moduleFor7conn
Browse files Browse the repository at this point in the history
Refactored file download
  • Loading branch information
afedyk-sugarcrm committed May 14, 2014
2 parents f9723ba + 69c0f5c commit 95bf05f
Showing 1 changed file with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down

0 comments on commit 95bf05f

Please sign in to comment.