diff --git a/src/Dmyers/Storage/Adapter/AmazonS3.php b/src/Dmyers/Storage/Adapter/AmazonS3.php index fa037c1..9956ca1 100644 --- a/src/Dmyers/Storage/Adapter/AmazonS3.php +++ b/src/Dmyers/Storage/Adapter/AmazonS3.php @@ -235,7 +235,17 @@ public function files($path) */ public function url($path) { - return $this->client->getObjectUrl($this->bucket, $this->computePath($path)); + $url = $this->client->getObjectUrl($this->bucket, $this->computePath($path)); + + if ($cname = $this->config('cname')) { + return str_replace( + parse_url($url, PHP_URL_HOST), + $cname, + str_replace("{$this->config('bucket')}/", '', $url) + ); + } + + return $url; } protected function ensureBucketExists() diff --git a/src/config/config.php b/src/config/config.php index 90907be..2aec454 100644 --- a/src/config/config.php +++ b/src/config/config.php @@ -27,6 +27,7 @@ 'secret' => '', 'region' => 'us-east-1', 'bucket' => '', + 'cname' => '', 'acl' => 'public-read', ),