Skip to content

Commit

Permalink
Issue #2401101: Fix the external URL generation
Browse files Browse the repository at this point in the history
  • Loading branch information
justafish committed Jan 3, 2015
1 parent 185f732 commit 5470b29
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions AmazonS3StreamWrapper.inc
Expand Up @@ -125,16 +125,16 @@ class AmazonS3StreamWrapper implements DrupalStreamWrapperInterface {
if (variable_get('amazons3_cname', 0)) {
$domain = variable_get('amazons3_domain', '');
if (strlen($domain) > 0) {
$this->domain = '//' . $domain;
$this->domain = $domain;
}
else {
$this->domain = '//' . $this->bucket;
$this->domain = $this->bucket;
}

$this->cloudfront = variable_get('amazons3_cloudfront', TRUE);
}
else {
$this->domain = '//' . $this->bucket . '.s3.amazonaws.com';
$this->domain = $this->bucket . '.s3.amazonaws.com';
}

// Check whether local file caching is turned on.
Expand Down Expand Up @@ -218,6 +218,7 @@ class AmazonS3StreamWrapper implements DrupalStreamWrapperInterface {
* Returns a string containing a web accessible URL for the resource.
*/
public function getExternalUrl() {
global $is_https;

// Image styles support
// Delivers the first request to an image from the private file system
Expand Down Expand Up @@ -297,8 +298,11 @@ class AmazonS3StreamWrapper implements DrupalStreamWrapperInterface {
)
);
}
elseif ($info['https']) {
$url = 'https:' . $url;
elseif ($info['https'] || $is_https) {
$url = 'https://' . $url;
}
else {
$url = 'http://' . $url;
}

return $url;
Expand Down

0 comments on commit 5470b29

Please sign in to comment.