> > I'm trying to figure out a way to stream a file to a remote 
> > user, and be able to determine that the download completed, 
> > so I can delete the file being streamed.  I may be missing an 
> > obvious way to do this, so I'm hoping you all can help me out.
> > 
> > Here's the sequence of events I'm after:
> > 
> > 1.  User clicks URL pointing to perl script.
> > 2.  Perl script pulls file out of LDAP, and writes it 
> > temporarily to disk.
> > 3.  File is uudecoded on the disk.
> > 4.  Decoded file is streamed to user, who saves the file locally.
> > 5.  Once it is determined that the download is complete, the 
> > temp file on the web server is deleted.
> > 
> > 
> > Steps 4 and 5 are what I'm really after - the rest is 
> > relatively straight forward.  For security reasons, we don't 
> > want the file to remain on the web server filesystem any 
> > longer than it has to, which is why I need to delete it after 
> > being downloaded.  Emailing the file is not an option, also 
> > due to security reasons.
> > 
> > Can anyone help me out with a way to do this?
> 
> Hi Jason,
> 
> maybe I don't get the point, but I don't think you need to do anything
> special but 
> sending an HTTP header and the file's content - something like:
> 
>   #!c:/perl/bin/perl.exe -w
> 
>   use strict;
>   use FileHandle;
> 
>   print "content-type: text/plain\n\n";
> 
>   # this would be the point to pull the file out of LDAP and decode it...
> 
>   # open the file you need to open, convert/decode it
>   my $fh = new FileHandle;
> 
>   open ($fh, "dynamicdownload.pl") or print "could not open the file! :
> $!\n";
>   while (<$fh>) {
>       print "$. $_";
>   }
>   close ($fh) or print "could not close the file\n";
> 
>   # commit suicide
>   unlink "dynamicdownload.pl";
> 
> Save this into a file called "dynamicdownload.pl" and put it into your web
> serverīs
> cgi-bin directory.
> The script will open itself, print itself out with line numbers in front,
> and delete
> itself afterwards (be careful! ;-) ). If I understand you correctly, you
> would just
> need to insert the connect to LDAP in front and change the name of the
file
> that should
> be opened for reading and deleted...or do I get something wrong here?
> 

Sounds right to me, except I think you can go one step further, assuming
you can open the file from LDAP as a handle, stream the handle through
the decoder, then there is no reason to ever store the file to the local
disk, this can be done in memory (which is still not absolutely secure,
but generally more so than the local disk), then stream the file to the
browser.  No need to worry about unlinking a temp file.

Of course, the question then becomes how are you accessing your LDAP
store and/or doing the decoding.

http://danconia.org


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to