/** * {@inheritdoc} */ public function getExternalUrl() { if (!isset($this->uri)) { throw new \LogicException('A URI must be set before calling getExternalUrl().'); } $path_segments = $this->uri->getPathSegments(); $args = array(); // Image styles support // Delivers the first request to an image from the private file system // otherwise it returns an external URL to an image that has not been // created yet. if ($path_segments[0] === 'styles' && !file_exists((string) $this->uri)) { return $this->url($this::stylesCallback . '/' . $this->uri->getBucket() . $this->uri->getPath(), array('absolute' => TRUE)); } // UI overrides. // Save as. $expiry = NULL; if ($this->forceDownload()) { $args['ResponseContentDisposition'] = $this->getContentDispositionAttachment(); $expiry = time() + 60 * 60 * 24; } // Torrent URLs. $path = $this->getLocalPath(); if ($this->useTorrent()) { $path .= '?torrent'; } if ($presigned = $this->usePresigned()) { $expiry = time() + $presigned->getTimeout(); } // @codeCoverageIgnoreStart if ($expiry && $this->config->isCloudFront()) { $url = $this->getCloudFrontUrl($path, $expiry); } else { // Generate a standard URL. $url = $this->getS3Url($path, $expiry, $args); } return (string) $url; }