You are here

public function S3::getExternalUrl in Flysystem - S3 8

Same name and namespace in other branches
  1. 2.0.x src/Flysystem/S3.php \Drupal\flysystem_s3\Flysystem\S3::getExternalUrl()

Returns a web accessible URL for the resource.

This function should return a URL that can be embedded in a web page and accessed from a browser. For example, the external URL of "youtube://xIpLd0WQKCY" might be "http://www.youtube.com/watch?v=xIpLd0WQKCY".

Parameters

string $uri: The URI to provide a URL for.

Return value

string Returns a string containing a web accessible URL for the resource.

Overrides FlysystemPluginInterface::getExternalUrl

File

src/Flysystem/S3.php, line 190

Class

S3
Drupal plugin for the "S3" Flysystem adapter.

Namespace

Drupal\flysystem_s3\Flysystem

Code

public function getExternalUrl($uri) {
  if ($this->isPublic === FALSE) {
    return $this
      ->getDownloadlUrl($uri);
  }
  $target = $this
    ->getTarget($uri);
  if (strpos($target, 'styles/') === 0 && !file_exists($uri)) {
    $this
      ->generateImageStyle($target);
  }
  return $this->urlPrefix . '/' . UrlHelper::encodePath($target);
}