- Posts: 78
- Thank you received: 0
Downloading big files fails
11 years 9 months ago #182168
by 121261
Downloading big files fails was created by 121261
-- HikaShop version -- : 2.3.4
-- Joomla version -- : 3.3.6
Hi there
we have very big files for download and the downloads breaks halfway.
In that regard PHP download method is not the best way to handle big files.
Can hikashop make use of Apache`s X-Sendfile; its the most reliable method. Apache serves the download giving you the best performance. Files are also protected by a .htaccess file making this method secure.
Or what about Amazon S3 or Cloud download services.
Please advise
regards
Bison
-- Joomla version -- : 3.3.6
Hi there
we have very big files for download and the downloads breaks halfway.
In that regard PHP download method is not the best way to handle big files.
Can hikashop make use of Apache`s X-Sendfile; its the most reliable method. Apache serves the download giving you the best performance. Files are also protected by a .htaccess file making this method secure.
Or what about Amazon S3 or Cloud download services.
Please advise
regards
Bison
Please Log in or Create an account to join the conversation.
11 years 9 months ago #182175
by nicolas
Replied by nicolas on topic Downloading big files fails
Hi,
I actually had never heard of X-Sendfile until today.
That's a really good idea and easy to implement.
Add the code:
after the code:
in the file administrator/components/com_hikashop/classes/file.php and if you have mod_xsendfile configured on your web server, it will use it to send the files. Please note that this requires that mod_xsendfile is installed and correctly configured to allow the sending of the files from the upload secure folder of HikaShop (default location is media/com_hikashop/upload/safe), otherwise, it will use the normal send process or not send anything.
Please let us know how it goes so that we can add it to next version of HikaShop.
I actually had never heard of X-Sendfile until today.
That's a really good idea and easy to implement.
Add the code:
Code:
if(function_exists('apache_get_modules')){
$modules = apache_get_modules();
if (is_array($modules) && count($modules) && in_array('mod_xsendfile', $modules)) {
// If mod_xsendfile is loaded, use X-Sendfile to deliver...
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $name . '"');
header("Cache-Control: maxage=1");
header("Pragma: public");
header("Content-Transfer-Encoding: binary");
header('X-Sendfile: ' . $filename);
$dispatcher->trigger( 'onAfterDownloadFile', array( &$filename, &$file) );
exit;
}
}
Code:
$name = (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) ?
preg_replace('/\./', '%2e', $fileinfo['basename'], substr_count($fileinfo['basename'], '.') - 1) :
$fileinfo['basename'];
Please let us know how it goes so that we can add it to next version of HikaShop.
Please Log in or Create an account to join the conversation.
11 years 5 months ago #197293
by nicolas
Replied by nicolas on topic Downloading big files fails
This was added in HikaShop 2.3.5
Please Log in or Create an account to join the conversation.
Time to create page: 0.170 seconds