467,109 Members | 1,345 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,109 developers. It's quick & easy.

How to download big file

I need to download a 200MB file from server. I wrote a server side porgram in perl like this
Expand|Select|Wrap|Line Numbers
  1. $ID = $xmlPath."PSIRT_EOX_OFFLINE.txt";
  2.  
  3.  
  4.       if ($ID eq '') {  
  5.       print "Content-type: text/html\n\n";  
  6.       print "You must specify a file to download.";  
  7.       } else {
  8.       print "Content-Type:application/x-download\n"; 
  9.       print "Content-Disposition:attachment;filename=PSIRT_EOX_OFFLINE.txt\n\n";
  10.       open(DLFILE, "$ID") || Error();
  11.         @fileholder = <DLFILE>;
  12.  
  13.       #binmode(DLFILE);
  14.  
  15.       close (DLFILE) || Error ('close', 'file');
  16.  
  17.       print "Content-Type:application/x-download\n"; 
  18.       print "Content-Length: $size\n";
  19.        print "Content-Disposition:attachment;filename=PSIRT_EOX_OFFLINE.txt\n\n";
  20.         print @fileholder ;
When I execute the perl script through browser, it takes around two mins time to popup the file download dialog. How can the time be reduced? Any help?
May 20 '08 #1
  • viewed: 2515
Share:
5 Replies
KevinADC
Expert 2GB
I need to download a 200MB file from server. I wrote a server side porgram in perl like this
$ID = $xmlPath."PSIRT_EOX_OFFLINE.txt";


if ($ID eq '') {
print "Content-type: text/html\n\n";
print "You must specify a file to download.";
} else {
print "Content-Type:application/x-download\n";
print "Content-Disposition:attachment;filename=PSIRT_EOX_OFFLINE. txt\n\n";
open(DLFILE, "$ID") || Error();
@fileholder = <DLFILE>;

#binmode(DLFILE);

close (DLFILE) || Error ('close', 'file');

print "Content-Type:application/x-download\n";
print "Content-Length: $size\n";
print "Content-Disposition:attachment;filename=PSIRT_EOX_OFFLINE. txt\n\n";
print @fileholder ;

When I execute the perl script through browser, it takes around two mins time to popup the file download dialog. How can the time be reduced? Any help?

Why have you printed the download header twice? I don't know if that is creating a problem but is certainly is not necessary. Ty like this and see if it helps:

Expand|Select|Wrap|Line Numbers
  1. if ($ID eq '') {  
  2.    print "Content-type: text/html\n\n";  
  3.    print "You must specify a file to download."; 
  4.    exit; 
  5. }
  6. else {
  7.    $size = -s $ID; 
  8.    open(DLFILE, $ID) or Error();
  9.    print "Content-Type:application/x-download\n"; 
  10.    print "Content-Length: $size\n";
  11.    print "Content-Disposition:attachment;filename=PSIRT_EOX_OFFLINE.txt\n\n";
  12.    print <DLFILE>;
  13.    close (DLFILE) or Error ('close', 'file');
  14. }
  15.  
May 20 '08 #2
Why have you printed the download header twice? I don't know if that is creating a problem but is certainly is not necessary. Ty like this and see if it helps:

Expand|Select|Wrap|Line Numbers
  1. if ($ID eq '') {  
  2.    print "Content-type: text/html\n\n";  
  3.    print "You must specify a file to download."; 
  4.    exit; 
  5. }
  6. else {
  7.    $size = -s $ID; 
  8.    open(DLFILE, $ID) or Error();
  9.    print "Content-Type:application/x-download\n"; 
  10.    print "Content-Length: $size\n";
  11.    print "Content-Disposition:attachment;filename=PSIRT_EOX_OFFLINE.txt\n\n";
  12.    print <DLFILE>;
  13.    close (DLFILE) or Error ('close', 'file');
  14. }
  15.  
I tried with this code but didn't get any solution.
May 21 '08 #3
KevinADC
Expert 2GB
tyr with a small file and see if the dialog box appears sooner. I am not sure if the size of the file has anything to do with the delay.
May 21 '08 #4
tyr with a small file and see if the dialog box appears sooner. I am not sure if the size of the file has anything to do with the delay.
Yes. I tried with a small file. It appears immediatly. But I want to do it with a big file. Isn't there any way to do it?
May 22 '08 #5
KevinADC
Expert 2GB
I don't know, I don't think this has anything to do with perl, more of a server issue.
May 22 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Buddy Ackerman | last post: by
4 posts views Thread by Nathan Sokalski | last post: by
1 post views Thread by a.r.austin@gmail.com | last post: by
3 posts views Thread by tshad | last post: by
reply views Thread by kain razial | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.