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); } } } }
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; } } } }