Downloading big files fails

  • Posts: 78
  • Thank you received: 0
9 years 11 months ago #182168

-- 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

Please Log in or Create an account to join the conversation.

  • Posts: 82864
  • Thank you received: 13372
  • MODERATOR
9 years 11 months ago #182175

Hi,

I actually had never heard of X-Sendfile until today.
That's a really good idea and easy to implement.
Add the 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;
			}
		}
after the code:
$name = (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) ?
						preg_replace('/\./', '%2e', $fileinfo['basename'], substr_count($fileinfo['basename'], '.') - 1) :
						$fileinfo['basename'];
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.

Please Log in or Create an account to join the conversation.

  • Posts: 82864
  • Thank you received: 13372
  • MODERATOR
9 years 7 months ago #197293

This was added in HikaShop 2.3.5

Please Log in or Create an account to join the conversation.

Time to create page: 0.056 seconds
Powered by Kunena Forum