Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Temp file strategy

by Tanktalus (Canon)
on Sep 16, 2005 at 00:10 UTC ( #492473=note: print w/replies, xml ) Need Help??


in reply to Temp file strategy

Is it possible to not create the temp file until the user selects to download it, but to provide a link with all the CGI parms needed to generate the file? Then you can generate it directly to stdout (aka, the socket via apache).

I don't think any of the temp file solutions written above will work across invocations of your CGI code since they will all remove the file as your script exits, too early for the user to click on a link to download.

Replies are listed 'Best First'.
Re^2: Temp file strategy
by signal9 (Pilgrim) on Sep 17, 2005 at 13:27 UTC
    "Is it possible to not create the temp file until the user selects to download it...?"

    Sure, just output your preferred filetype w/ proper MIME type just like you would a web page. Nothing fancy at all, and I've been known to do this.

    "I don't think any of the temp file solutions written above will work across invocations of your CGI..."

    Reread the above example. Files are deleted after an arbitrary "timeout". We do this alot for CSV downloads of reports where I work. Usually we do 24hrs. Sure, if someone runs a report, but doesn't click on the CSV link until sometime tomorrow the file will be gone. I don't think that's unreasonable, but it's really up to you how long the file sticks around.

    Of course, these are hand-rolled solutions. I think I'm going to have to look into the File::Temp module folks keep talking about.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://492473]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (12)
As of 2019-10-22 13:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?