How to download big file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nitupatra
    New Member
    • Mar 2008
    • 7

    #1

    How to download big file

    I need to download a 200MB file from server. I wrote a server side porgram in perl like this
    [CODE=perl]$ID = $xmlPath."PSIRT _EOX_OFFLINE.tx t";


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

    #binmode(DLFILE );

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

    print "Content-Type:applicatio n/x-download\n";
    print "Content-Length: $size\n";
    print "Content-Disposition:att achment;filenam e=PSIRT_EOX_OFF LINE.txt\n\n";
    print @fileholder ;[/CODE]

    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?
    Last edited by eWish; May 20 '08, 07:43 PM. Reason: Please use code tags
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    Originally posted by nitupatra
    I need to download a 200MB file from server. I wrote a server side porgram in perl like this
    $ID = $xmlPath."PSIRT _EOX_OFFLINE.tx t";


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

    #binmode(DLFILE );

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

    print "Content-Type:applicatio n/x-download\n";
    print "Content-Length: $size\n";
    print "Content-Disposition:att achment;filenam e=PSIRT_EOX_OFF LINE.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:

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

    Comment

    • nitupatra
      New Member
      • Mar 2008
      • 7

      #3
      Originally posted by KevinADC
      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:

      Code:
      if ($ID eq '') {  
         print "Content-type: text/html\n\n";  
         print "You must specify a file to download."; 
         exit; 
      }
      else {
         $size = -s $ID; 
         open(DLFILE, $ID) or Error();
         print "Content-Type:application/x-download\n"; 
         print "Content-Length: $size\n";
         print "Content-Disposition:attachment;filename=PSIRT_EOX_OFFLINE.txt\n\n";
         print <DLFILE>;
         close (DLFILE) or Error ('close', 'file');
      }
      I tried with this code but didn't get any solution.

      Comment

      • KevinADC
        Recognized Expert Specialist
        • Jan 2007
        • 4092

        #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.

        Comment

        • nitupatra
          New Member
          • Mar 2008
          • 7

          #5
          Originally posted by KevinADC
          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?

          Comment

          • KevinADC
            Recognized Expert Specialist
            • Jan 2007
            • 4092

            #6
            I don't know, I don't think this has anything to do with perl, more of a server issue.

            Comment

            Working...