/** * @brief store a file in a simplier way * * @param the FileInterface file to be stored * @param optional driver storage where to be stored * By default the same driver will be used (this * scenario is the best when using local files) * * @return string uri */ public function store(FileInterface $file, StorageInterface $driver = null) { $uri = new UriParser($file->uri()); $storage = $this->findBySchema($uri->getSchema()); $driver = $driver === null ? $storage : $driver; return $driver->store($storage->fileDescriptor($file)); }
/** * (non-PHPdoc) * @see \Softservlet\FileManager\Deliver\DeliveryInterface::httpUrl() */ public function httpUrl(FileInterface $file) { $uri = new UriParser($file->uri()); if ($uri->getSchema() !== 'file') { throw new Exception("This driver supports only the 'file' schema"); } $path = base_path(); $location = str_replace($path, '', $uri->getLocation()); $location = trim($location, '/'); return asset($location); }
/** * @return the URiParser object for this File * */ public function uri() { return new UriParser($this->file->uri()); }
/** * @brief set the file * * @param FileInterface file */ public function setFile(FileInterface $file) { $this->file = $file; $uri = new UriParser($file->uri()); $this->location = $uri->getLocation(); }