Пример #1
0
 /**
  * Set the Filesystem object.
  *
  * @param FilesystemInterface $filesystem
  */
 public function setFilesystem(FilesystemInterface $filesystem)
 {
     parent::setFilesystem($filesystem);
     if ($filesystem instanceof Filesystem) {
         $this->adapter = $filesystem->getAdapter();
         // For a cached adapter, get the underlying instance
         if ($this->adapter instanceof CachedAdapter) {
             $this->adapter = $this->adapter->getAdapter();
         }
         //TODO: Check on actual implementations, not just an existing method
         $this->hasMethod = method_exists($this->adapter, 'getUrl');
     }
 }
Пример #2
0
 /**
  * {@inheritdoc}
  *
  * @throws \RuntimeException
  */
 public function url(string $path) : string
 {
     $adapter = $this->driver->getAdapter();
     if ($adapter instanceof AwsS3Adapter) {
         $path = $adapter->getPathPrefix() . $path;
         return $adapter->getClient()->getObjectUrl($adapter->getBucket(), $path);
     } elseif ($adapter instanceof LocalAdapter) {
         return $adapter->getPathPrefix() . $path;
     } elseif (method_exists($adapter, 'getUrl')) {
         return $adapter->getUrl($path);
     }
     throw new RuntimeException('This driver does not support retrieving URLs.');
 }