예제 #1
0
파일: TrackAdd.php 프로젝트: EQ4/smafe
 protected function download()
 {
     $filename = $this->fileURL;
     $this->localFile = null;
     if (file_exists($filename)) {
         // local file
         $this->localFile = $this->fileURL;
     } else {
         // might be remote file
         // try to download
         // check if remote location exists
         if (RestUtils::url_exists($this->fileURL)) {
             $tmpName = tempnam(sys_get_temp_dir(), 'smafe_');
             $tmpFilename = $tmpName . '_' . basename($this->fileURL);
             $success = copy($this->fileURL, $tmpFilename);
             if ($success) {
                 $this->localFile = $tmpFilename;
                 //log the file download and create a local urlinfo file
                 MyLog::printWithDuration("Downloaded URL: {$this->fileURL} to Local File: {$this->localFile}");
                 $handle = fopen($tmpName, "w");
                 fwrite($handle, "local     : {$this->localFile}\n");
                 fwrite($handle, "url       : {$this->fileURL}\n");
                 fwrite($handle, "ext key   : {$this->external_key}\n");
                 fwrite($handle, "collection: {$this->collection}\n");
                 fclose($handle);
             }
         }
     }
 }
예제 #2
0
파일: TrackLive.php 프로젝트: EQ4/smafe
 protected function download()
 {
     $filename = $this->fileURL;
     $this->localFile = null;
     if (file_exists($filename)) {
         // local file
         $this->localFile = $this->fileURL;
     } else {
         // might be remote file
         // try to download
         // check if remote location exists
         if (RestUtils::url_exists($this->fileURL)) {
             $tmpFilename = tempnam(sys_get_temp_dir(), 'smafe_') . '_' . basename($this->fileURL);
             $success = copy($this->fileURL, $tmpFilename);
             if ($success) {
                 $this->localFile = $tmpFilename;
             }
         }
     }
 }