Gz Compression on the fly

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zlash
    New Member
    • Dec 2007
    • 9

    #1

    Gz Compression on the fly

    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.
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Zlash.

    Check out flush().

    Comment

    • zlash
      New Member
      • Dec 2007
      • 9

      #3
      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.

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        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.

        Comment

        Working...