You are here

public function PrivateS3fsStream::getExternalUrl in S3 File System 8.3

Same name and namespace in other branches
  1. 4.0.x src/StreamWrapper/PrivateS3fsStream.php \Drupal\s3fs\StreamWrapper\PrivateS3fsStream::getExternalUrl()

Returns a web accessible URL for the resource.

The format of the returned URL will be different depending on how the S3 integration has been configured on the S3 File System admin page.

Return value

string A web accessible URL for the resource.

Overrides S3fsStream::getExternalUrl

File

src/StreamWrapper/PrivateS3fsStream.php, line 32

Class

PrivateS3fsStream
Defines a Drupal s3fs stream wrapper class for use with private scheme.

Namespace

Drupal\s3fs\StreamWrapper

Code

public function getExternalUrl() {
  $s3_key = str_replace('\\', '/', $this->streamWrapperManager::getTarget($this->uri));
  return Url::fromRoute('system.private_file_download', [
    'filepath' => $s3_key,
  ], [
    'absolute' => TRUE,
    'path_processing' => FALSE,
  ])
    ->toString();
}