Skip to content

Commit

Permalink
Custom fixes - PRs that aren't merged from servdhost/craft-remote-ass…
Browse files Browse the repository at this point in the history
…ets (#1)
  • Loading branch information
peimansh authored Mar 8, 2021
1 parent 547a5af commit 5376347
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "servd/craft-remote-assets",
"description": "Move CP assets to an external filesystem such as S3",
"type": "craft-plugin",
"version": "0.1.7",
"version": "0.1.8",
"keywords": [
"craft",
"cms",
Expand All @@ -24,8 +24,7 @@
],
"require": {
"craftcms/cms": "^3.0.0",
"aws/aws-sdk-php": "^3.61.0",
"google/cloud-storage": "^1.3.0"
"aws/aws-sdk-php": "^3.173.23"
},
"autoload": {
"psr-4": {
Expand Down
11 changes: 9 additions & 2 deletions src/S3RemoteAssetStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,15 @@ public function putFile($key, $local, $contentType)
public function getURLForKey($key)
{
$config = CraftRemoteAssets::getInstance()->getSettings()->s3Config;
return 'https://s3-' .
$config['region'] .

// If a CloudFront CDN URL has been provided, append only the 'root' and asset $key
if (!empty($config['cloudfrontUrl'])) {
return $config['cloudfrontUrl'] . '/' .
$config['root'] . '/' .
$key;
}

return 'https://s3' .
'.amazonaws.com/' .
$config['bucket'] . '/' .
$config['root'] . '/' .
Expand Down
2 changes: 1 addition & 1 deletion src/models/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Settings extends Model
public function rules()
{
return [
[['use', 's3Config', 'gcConfig'], 'required'],
[['use', 's3Config', 'gsConfig'], 'required'],
];
}
}

0 comments on commit 5376347

Please sign in to comment.