stonecolddevin has asked for the wisdom of the Perl Monks concerning the following question:

Good day monks,
I've been thinking about a web authoring project that includes creating html pages. I was wondering how I might, after the user is done working on their page, give the user the option of zipping their page up on my server space, and putting it in a given directory for them to download? I've got no clue where to start with this, so any help is appreciated.
-Dhoss

And if you're feeling lucky... come and take me home And if you feel loved If you feel lucky, if you feel loved If you feel lucky, if you feel loved You've crossed the walls - Excelled Further along through their hell All for my heart, I watch you kill You always have, you always will Now spread your wings and sail out to me....
  • Comment on Creating an HTML file, then (g)zipping it up for a user to dl it?

Replies are listed 'Best First'.
Re: Creating an HTML file, then (g)zipping it up for a user to dl it?
by BazB (Priest) on Aug 09, 2003 at 22:03 UTC

    Look at mod_gzip for Apache. I discussed it here.
    RFC: Mod Perl compressed content has some other ideas that might help.

    Cheers,

    BazB


    If the information in this post is inaccurate, or just plain wrong, don't just downvote - please post explaining what's wrong.
    That way everyone learns.

Re: Creating an HTML file, then (g)zipping it up for a user to dl it?
by belg4mit (Prior) on Aug 09, 2003 at 22:04 UTC
    Sort of depends on what you're trying to do. Save bandwidth? Or by "webpage" do you mean the document and all the accoutrements (images, etc.)? For smaller HTML documents there's not much point in compressing an archive containing your average images etc. since they are precompressed. Instead a tar file should be sufficient. If you have mod_perl running you might take a look at Apache::GzipChain for some ideas.

    --
    I'm not belgian but I play one on TV.

      Interesting, thanks a bunch, I'll check it out right away.

      And if you're feeling lucky... come and take me home And if you feel loved If you feel lucky, if you feel loved If you feel lucky, if you feel loved You've crossed the walls - Excelled Further along through their hell All for my heart, I watch you kill You always have, you always will Now spread your wings and sail out to me....
Re: Creating an HTML file, then (g)zipping it up for a user to dl it?
by TomDLux (Vicar) on Aug 10, 2003 at 03:25 UTC

    The user types stuff and clicks buttons to define what the page should be like ... and views the result either in a separate frame, or clicks a button to view the page, every once in a while. Somehow, they have to see the page, right?

    So when the page is satisfactory, they select Save As... and save the files in some directory.

    --
    TTTATCGGTCGTTATATAGATGTTTGCA

      Exactly, actually. The only reason I want to zip it ( or tar it) is so the can download it, instead of having to use some other method such as viewing, copying and pasting the source, and saving it.

      And if you're feeling lucky... come and take me home And if you feel loved If you feel lucky, if you feel loved If you feel lucky, if you feel loved You've crossed the walls - Excelled Further along through their hell All for my heart, I watch you kill You always have, you always will Now spread your wings and sail out to me....
Re: Creating an HTML file, then (g)zipping it up for a user to dl it?
by blue_cowdawg (Monsignor) on Aug 10, 2003 at 15:13 UTC

    Based on what I can glean from this thread as to your intentions I think what you are after is Archive::Zip to create the archive and then you can send that archive to the browser in binary mode with the correct HTML headers being set. This is untested, but here is a sniglet of code that I think should work for you:

        #!/usr/bin/perl -w ################################3 use strict; use warnings; use diagnostics; use CGI; use Archive::Zip; my $cgi=new CGI; print $cgi->header("Content-type: x-applicaition/zip\n\n\n"); my $arch = new Archive::Zip; my $member = $arch->addFile('myfile.html'); binmode(STDOUT); # THis is suspect, I haven't done this for a while... +. $arch->writeToFilehandle(\*STDOUT); . . . .

    The only part I am hazy about is the binmode part since I haven't done that in a while. At any rate TIMTOWTDI.


    Peter @ Berghold . Net

    Sieze the cow! Bite the day!

    Nobody expects the Perl inquisition!

    Test the code? We don't need to test no stinkin' code!
    All code posted here is as is where is unless otherwise stated.

    Brewer of Belgian style Ales

      binmode only matters if you're on a win32 type host.

        True... but I don't remember him specifying he wasn't...


        Peter @ Berghold . Net

        Sieze the cow! Bite the day!

        Nobody expects the Perl inquisition!

        Test the code? We don't need to test no stinkin' code!
        All code posted here is as is where is unless otherwise stated.

        Brewer of Belgian style Ales