awohld has asked for the wisdom of the Perl Monks concerning the following question:
But it took several minutes to start the download, I assume because it was taking forever to load the file into the array.open(DLFILE, "<$file_location/$id") || Error('open', 'file'); @fileholder = <DLFILE>; close (DLFILE) || Error ('close', 'file'); print "Content-Type:application/x-download\n"; print "Content-Disposition: attachment;filename=$filename[0]\n\n"; print @fileholder
Now my downloads start a lot faster. Am I right to assume that my first code attempt took forever since I had to load the file into memory first. And my second attempt is faster since I send the headers first then start sending data when I read the first line? Is there a better way to do this?open(DLFILE, "<$file_location/$id") || Error('open', 'file'); print "Content-Type:application/x-download\n"; print "Content-Disposition: attachment;filename=$filename[0]\n\n"; while (<DLFILE>) { print $_; } close (DLFILE) || Error ('close', 'file');
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Improving a File Download Script
by ikegami (Patriarch) on Oct 13, 2005 at 06:12 UTC | |
|
Re: Improving a File Download Script
by neosamuri (Friar) on Oct 13, 2005 at 06:43 UTC | |
|
Re: Improving a File Download Script
by Skeeve (Parson) on Oct 13, 2005 at 06:14 UTC | |
|
Re: Improving a File Download Script
by pajout (Curate) on Oct 13, 2005 at 08:37 UTC |