Skip to content

Commit

Permalink
Merge pull request #47 from grebaldi/feature/proxySubDirectory
Browse files Browse the repository at this point in the history
FEATURE: Allow optional  key on resourceProxy configuration
  • Loading branch information
grebaldi authored Feb 23, 2021
2 parents 23568a7 + 6bcff06 commit 6e08442
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,13 @@ public function getStreamByResource(PersistentResource $resource)
$browser = new Browser();
$browser->setRequestEngine($curlEngine);

$subDirectory = $resourceProxyConfiguration['subDirectory'] ?? '_Resources/Persistent/';
$subdivideHashPathSegment = $resourceProxyConfiguration['subdivideHashPathSegment'] ?? false;
if ($subdivideHashPathSegment) {
$sha1Hash = $resource->getSha1();
$uri = $resourceProxyConfiguration['baseUri'] .'/_Resources/Persistent/' . $sha1Hash[0] . '/' . $sha1Hash[1] . '/' . $sha1Hash[2] . '/' . $sha1Hash[3] . '/' . $sha1Hash . '/' . rawurlencode($resource->getFilename());
$uri = $resourceProxyConfiguration['baseUri'] . '/' . $subDirectory . $sha1Hash[0] . '/' . $sha1Hash[1] . '/' . $sha1Hash[2] . '/' . $sha1Hash[3] . '/' . $sha1Hash . '/' . rawurlencode($resource->getFilename());
} else {
$uri = $resourceProxyConfiguration['baseUri'] .'/_Resources/Persistent/' . $resource->getSha1() . '/' . rawurlencode($resource->getFilename());
$uri = $resourceProxyConfiguration['baseUri'] . '/' . $subDirectory . $resource->getSha1() . '/' . rawurlencode($resource->getFilename());
}

$response = $browser->request($uri);
Expand Down
1 change: 1 addition & 0 deletions Configuration/Settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Sitegeist:
# # and instead resources are fetched and imported on the fly once read
# resourceProxy:
# baseUri: http://vour.server.tld
# subDirectory: _Resources/Persistent/
# subdivideHashPathSegment: false
# curlOptions:
# CURLOPT_USERPWD: very:secure
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ Sitegeist:
# and instead resources are fetched and imported on the fly once read
resourceProxy:
baseUri: http://vour.server.tld
# define an optional subDirectory (defaults to: '_Resources/Persistent/', trailing slash is required!)
subDirectory: '_Resources/Persistent/'
# define wether or not the remote uses subdivideHashPathSegments
subdivideHashPathSegment: false
# curl options
Expand Down

0 comments on commit 6e08442

Please sign in to comment.