/** * Validates the download file input. * * @throws UserInputException */ protected function validateDownloadFile() { if (FileUtil::isURL($this->downloadFile)) { //download file $parsedUrl = parse_url($this->downloadFile); $prefix = 'importSubscriber'; try { // file transfer via hypertext transfer protocol. if ($parsedUrl['scheme'] == 'http') { $this->downloadFile = FileUtil::downloadFileFromHttp($this->downloadFile, $prefix); } elseif ($parsedUrl['scheme'] == 'ftp') { $this->downloadFile = FTPUtil::downloadFileFromFtp($this->downloadFile, $prefix); } } catch (SystemException $e) { throw new UserInputException('downloadFile', 'notFound'); } } else { // probably local path if (!file_exists($this->downloadFile)) { throw new UserInputException('downloadFile', 'notFound'); } } }
/** * Downloads the package archive. * * @return string path to the dowloaded file */ public function downloadArchive() { $parsedUrl = parse_url($this->archive); $prefix = 'package'; // file transfer via hypertext transfer protocol. if ($parsedUrl['scheme'] == 'http') { $this->archive = FileUtil::downloadFileFromHttp($this->archive, $prefix); } elseif ($parsedUrl['scheme'] == 'ftp') { $this->archive = FTPUtil::downloadFileFromFtp($this->archive, $prefix); } // unzip tar $this->archive = self::unzipPackageArchive($this->archive); return $this->archive; }