Webiny\Component\Storage\Storage::getAbsolutePath PHP Method

getAbsolutePath() public method

Get absolute file path
Requires '\Webiny\Component\Storage\Driver\AbsolutePathInterface' to be implemented by a Driver class
public getAbsolutePath ( $key = '' ) : mixed
$key
return mixed
    public function getAbsolutePath($key = '')
    {
        if ($this->supportsAbsolutePaths()) {
            return $this->driver->getAbsolutePath($key);
        }
        throw new StorageException(StorageException::DRIVER_DOES_NOT_SUPPORT_ABSOLUTE_PATHS, [get_class($this->driver)]);
    }

Usage Example

Esempio n. 1
0
 /**
  * Get absolute file path.
  * If storage driver does not support absolute paths (cloud storage) returns file key
  *
  * @return string
  */
 public function getAbsolutePath()
 {
     if ($this->storage->supportsAbsolutePaths()) {
         return $this->storage->getAbsolutePath($this->key);
     }
     return $this->getKey();
 }