B
burak
I apologize in advance if this is off-topic (it may not be a Perl
question, it could be an HTTP thing? I'm not sure though, that's why
I'm asking... so please don't flame me!).
Regarding sending a binary file through perl. I assume this is one of
the many ways to do it:
print "Content-type: application/octet-stream\n\n";
open (FILE, "<foo.bar");
binmode(FILE);
print <FILE>;
close (FILE);
BUT, if the file is incomplete when this action occurs, the above code
sends only what's there when you open the file, and the download ends
abruptly. Err that's probably not too descriptive, so here's an
example of what I want to do:
Let's say I have some perl code to generate a very large binary file,
hundreds of megabytes or so. And let's say this code is pretty slow,
so it takes some time to generate this file. I'd like to start sending
the file to the user (as a download) before the file is generated
completely. If the download is faster than the file creation, I'd like
the download to sort of.. wait for the file to be completed. So lets
say the file is supposed to be 200 mb large, and so far the script has
only generated 100mb. Your download runs quickly, and you hit the 100
mb mark pretty quickly. Normally, the download would end there and you
have only half the file. How can i make this download wait until the
file is officially "done" (ie, reached 200 mb)? Is this a perl thing
or a browser thing? (I've looked a lot into the http headers for the
download; while there is a filesize parameter, this seems to be only
for convenience sake, and doesn't force the download to continue until
that filesize has been reached.)
I hope I've made this question significantly clear and I really hope
this is the correct group to post at. If not, please direct me to the
correct place. I try not to piss of the regulars
PS I realize that the normal solution to this problem would just be
"send the file when it's complete, duh" but that's not what I'm going
for. I want the user to start downloading the file as soon as it
starts being generated...
Thanks in advance
question, it could be an HTTP thing? I'm not sure though, that's why
I'm asking... so please don't flame me!).
Regarding sending a binary file through perl. I assume this is one of
the many ways to do it:
print "Content-type: application/octet-stream\n\n";
open (FILE, "<foo.bar");
binmode(FILE);
print <FILE>;
close (FILE);
BUT, if the file is incomplete when this action occurs, the above code
sends only what's there when you open the file, and the download ends
abruptly. Err that's probably not too descriptive, so here's an
example of what I want to do:
Let's say I have some perl code to generate a very large binary file,
hundreds of megabytes or so. And let's say this code is pretty slow,
so it takes some time to generate this file. I'd like to start sending
the file to the user (as a download) before the file is generated
completely. If the download is faster than the file creation, I'd like
the download to sort of.. wait for the file to be completed. So lets
say the file is supposed to be 200 mb large, and so far the script has
only generated 100mb. Your download runs quickly, and you hit the 100
mb mark pretty quickly. Normally, the download would end there and you
have only half the file. How can i make this download wait until the
file is officially "done" (ie, reached 200 mb)? Is this a perl thing
or a browser thing? (I've looked a lot into the http headers for the
download; while there is a filesize parameter, this seems to be only
for convenience sake, and doesn't force the download to continue until
that filesize has been reached.)
I hope I've made this question significantly clear and I really hope
this is the correct group to post at. If not, please direct me to the
correct place. I try not to piss of the regulars
PS I realize that the normal solution to this problem would just be
"send the file when it's complete, duh" but that's not what I'm going
for. I want the user to start downloading the file as soon as it
starts being generated...
Thanks in advance