By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,960 Members | 1,009 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,960 IT Pros & Developers. It's quick & easy.

Gz Compression on the fly

P: 9
Hello, I've been looking and trying a lot of things but I cant find a solution to this problem. Here it is the scenario, Im building a big tar file (about 70~100 Mb) on the fly, mainly fetching information from a MySQL DB and from other raw files of my own. The output file is very redundant so I want to encode it as gz to make it lighter.
The problem is this: The only way I came to encode it is using the php function gzencode, however I have first to build the tar file (I'm building it using Output Buffering) to pass the data to the encoding function. The process of building the tar file takes time, and no output is generated durating this time, so the "Save As..." Dialog doesn't show up until the output is started (As I stated, after building and gzipping the tar file).

Does anybody knows a way to tell the client that we are going to send a file but maybe we will delay to start delivering content?

Or there is a way to gzip chunks of data inside a gzip file?

Thanks in advance, and please excuse me for my bad English.
Dec 27 '07 #1
Share this Question
Share on Google+
3 Replies

Expert 5K+
P: 5,821
Heya, Zlash.

Check out flush().
Dec 31 '07 #2

P: 9
Thanks for your reply, but is not what im needing.

I dont have problem with the output buffering, is just that for gzipping the content, I must have all the file proccesed. While Im doing it, the "Download As" dialog will not appear. This is frustrating for users, as they think that download is not working. What Im looking for is a way to tell the web browser to present the dialog, even if we are not going to send data inmediately.

My current solution, is to start the tar structure, and put on it a file with only a space, this shows the dialog to the user. Then I include the tar.gz file inside the tar.

It """""works"""" but I dont like it. Its not clean, and Im sure that there is a better way to do it. Also, I waste a couple of NULL characters that should be compressed too.

Thanks again for your reply.
Dec 31 '07 #3

Expert 5K+
P: 5,821
Heya, Zlash.

You might want to create a download queuing system, where the User puts in his request to download the file, and then a window opens with an estimate of how long it will take to prepare the download. The window would refresh once a minute or so and present the User with a download link once the package was ready for download.
Jan 1 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.