0 Replies Latest reply on Oct 20, 2010 3:54 AM by daslicht

    Resumable Downloads, PHP

    daslicht Level 2

      Hello,


      Currently I use Filereference and PHP to offer hotlink protected downloads.

       

      How can I make those resumeable ?

       

      ...

      public function download():void

      {
           request = new URLRequest();
           request.method = URLRequestMethod.POST;
           request.url = "services/download/DownloadService.php";
                          
           params.fileName = _fileName;
                          
           request.data = params;
                          
           file = new FileReference();
           configureListeners( file );
                                              
           file.download(request, _fileName);
      }

      ...

       

      if( $fd = fopen($fullPath, "r") )
      {
           $fsize = filesize($fullPath);
           $path_parts = pathinfo($fullPath);
           $ext = strtolower($path_parts["extension"]);
           
                                 
                                
           header('Content-Description: File Transfer');
           header('Content-Type: application/octet-stream');
           header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\""); // use 'attachment' to force a download
           header('Content-Transfer-Encoding: binary');
                               
           header("Content-length: $fsize");
           header("Cache-control: private"); //use this to open files directly
           while(!feof($fd))
           {
                $buffer = fread($fd, 2048);
                echo $buffer;
                                 
                                 
           }

      }