in reply to Re: CGI.pm and Large File Transfers
in thread CGI.pm and Large File Transfers

The more I think about this challenge, the less I think the http solution will work and still be reliable (http certainly was not designed for it).

As for upload_hook, I found it in the CGI.pm page on CPAN.org:

You can set up a callback that will be called whenever a file upload is being read during the form processing. This is much like the UPLOAD_HOOK facility available in Apache::Request, with the exception that the first argument to the callback is an Apache::Upload object, here it's the remote filename.
$q = CGI->new(); $q->upload_hook(\&hook,$data); sub hook { my ($filename, $buffer, $bytes_read, $data) = @_; print "Read $bytes_read bytes of $filename\n"; }

If using the function-oriented interface, call the CGI::upload_hook() method before calling param() or any other CGI functions:
CGI::upload_hook(\&hook,$data);

This method is not exported by default. You will have to import it explicitly if you wish to use it without the CGI:: prefix.

Replies are listed 'Best First'.
Re: Re: Re: CGI.pm and Large File Transfers
by iburrell (Chaplain) on Mar 16, 2004 at 21:31 UTC
    HTTP is just as reliable and fast as FTP. More reliable since there is only one connection instead of the separate data connection with FTP so less firewall worries. And you don't have to worry about a separate server with different authentication.

    Also, if you don't need other form fields (including the filename), then you can do a POST with the file content as the body. The receiving CGI would not use CGI.pm to parse the upload but read the body directly and save it to disk. The filename would have to be constructed by some other mechanism.