Zen Cart Logo
Forums / General Questions / Gzip and Downloads

Gzip and Downloads

Locked

Views: 2,267

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
17 May 2006, 9:29 PM
#1
whatarerecords avatar

whatarerecords

New Zenner

Join Date:
Feb 2006
Posts:
3
Plugin Contributions:
0

Gzip and Downloads

Hello All,

So, after countless hours of searching forums and newsgroups and I've finally just given up on forcing the downbloads of mp3s (as opposed to streaming them). Instead, does anyone know how to have ZC automatically gzip all mp3s being purchased into one .zip file? This would effectively solve two problems:

-No more worrying about streaming single files.

-Purchases of multiple songs would be downloaded as one file, rather than having to d/l each one individually.

I believe modifying the download headers could accomplish this, but I don't really know where to go from there.

If someone knows, I'd be deeply appreciative...

bob

What Are Records?

19 May 2006, 3:51 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Gzip and Downloads

It would be more simple if you simply zipped all your MP3's before uploading. That would fix things right away.

Or, you could dig out your advanced PHP coding manuals and peek at the code in includes/modules/pages/downloads/header_php.php to write code that identifies all downloads in an order, zips them, and then streams the zip. Either way the customer has to unzip them after downloading. You'll have to adjust all other places in the code where individual file downloads are shown so that they all use your new code to download only a single file.

Much simpler to just zip before uploading.

19 May 2006, 4:49 PM
#3
whatarerecords avatar

whatarerecords

New Zenner

Join Date:
Feb 2006
Posts:
3
Plugin Contributions:
0

Re: Gzip and Downloads

Thanks for the reply,

Normally I agree that it would be simpler to zip every individual file, but when you are dealing with hundreds of albums, each with between 10 and 20 tracks, that can get to be a lot of zipping and file naming.

I don't mind the customer having to unzip a file, we're not iTunes and hopefully our people can understand that. If not, well, that's just the way it is.

The nice thing about the dynamic zipping is that people can pick and chose as many or as few tracks as they like, yet recieve a single zip file with everything they purchased,

So, with that said, downloads/header.php is the place to be. If anyone has done this and has some snippets of code on how to accomplish this, I'd be grateful. If not, I guess now's as a good a time as any to learn how to write it myself...

Once again, thanks for your reply.

bob

20 May 2006, 7:42 AM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Gzip and Downloads

You can likely make it easier on yourself and just tell it to zip the (single) file before downloading. .... so , just before it creates the symlink in the pub folder for download, tell it to zip the file.

This won't batch-zip all the files in the order, but at least it'll stop the streaming of the MP3's.

The challenge will be in deciding "how" to zip the files ... ie: what "zip" format you intend to use, and what your server enables you to do...without installing extra software on the server (unless your host will do that for you).

24 May 2006, 8:19 PM
#5
whatarerecords avatar

whatarerecords

New Zenner

Join Date:
Feb 2006
Posts:
3
Plugin Contributions:
0

Re: Gzip and Downloads

Thanks again for the response. I'm having a little difficulty getting the single file to zip.

Please don't mock my amatuer attempt at coding this :) I'm placing this right before it creates the symlink:

{ case 'zip':

          @exec(LOCAL_EXE_ZIP . ' -j ' . DIR_FS_DOWNLOAD . $file . '.zip ' . DIR_FS_DOWNLOAD . $file);

          if (file_exists(DIR_DL_FILE . $file) && file_exists(DIR_DL_FILE . $file . 'zip')) unlink(DIR_FS_DOWNLOAD . $file);

          $file .= '.zip';

and of course I get a parse error. Which what happens essentially everytime I try and write something...

Thanks again for taking the time to answer my questions

bob

What Are Records?