/** * Return the web-accessible uri for the given file. * * @param string $file * @return string The file uri * @throws \RuntimeException */ public function uri($file) { if (null !== $this->filenameFilter) { $file = $this->filenameFilter->filter($file); } try { $request = $this->s3Client->get($this->getBucket() . '/' . $file); return $this->s3Client->getPresignedUrl($request, $this->getUriExpirationTime()); } catch (S3Exception $e) { if (!$this->getThrowExceptions()) { return null; } throw new \RuntimeException('Exception thrown by Aws\\S3\\S3Client: ' . $e->getMessage(), null, $e); } }
/** * Creates url to S3 object * @param string $filePath * @param boolean $thumbnail * @return mixed */ protected function getS3Url($filePath, $thumbnail = false) { $path = $thumbnail ? $this->get_thumbnail($filePath) : $filePath; if ($this->config['s3']['presignUrl']) { return $this->s3->getPresignedUrl($path, '+10 minutes'); } else { // TODO: is non-presigned url might be created in place, without extra request ? //sprintf('//%s/%s', $this->domain, $this->bucket.'/'.$path) return $this->s3->getUrl($path); } }