/** * @param $jobid * @param $get_file */ public function file_download($jobid, $get_file) { try { $sugarsync = new BackWPup_Destination_SugarSync_API(BackWPup_Option::get($jobid, 'sugarrefreshtoken')); $response = $sugarsync->get(urldecode($get_file)); if ($level = ob_get_level()) { for ($i = 0; $i < $level; $i++) { ob_end_clean(); } } @set_time_limit(300); nocache_headers(); header('Content-Description: File Transfer'); header('Content-Type: ' . BackWPup_Job::get_mime_type((string) $response->displayName)); header('Content-Disposition: attachment; filename="' . (string) $response->displayName . '"'); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . (int) $response->size); echo $sugarsync->download(urldecode($get_file)); die; } catch (Exception $e) { die($e->getMessage()); } }
/** * @param $jobid * @param $get_file */ public function file_download($jobid, $get_file) { try { $sugarsync = new BackWPup_Destination_SugarSync_API(BackWPup_Option::get($jobid, 'sugarrefreshtoken')); $response = $sugarsync->get(urldecode($get_file)); header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=" . (string) $response->displayName . ";"); header("Content-Transfer-Encoding: binary"); header("Content-Length: " . (int) $response->size); @set_time_limit(0); echo $sugarsync->download(urldecode($get_file)); die; } catch (Exception $e) { die($e->getMessage()); } }