Skip to content

Commit dad7eaf

Browse files
author
Jamie Hannaford
committed
Merge pull request #653 from mediasuitenz/working
Fix temp public URL missing file path info
2 parents 48bacdc + 1b57e79 commit dad7eaf

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/OpenCloud/ObjectStore/Resource/DataObject.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,11 @@ public function getTemporaryUrl($expires, $method, $forcePublicUrl = false)
481481
}
482482
// @codeCoverageIgnoreEnd
483483

484-
$url = ($forcePublicUrl === true) ? $this->getService()->getEndpoint()->getPublicUrl() : $this->getUrl();
484+
$url = $this->getUrl();
485+
if ($forcePublicUrl === true) {
486+
$url->setHost($this->getService()->getEndpoint()->getPublicUrl()->getHost());
487+
}
488+
485489
$urlPath = urldecode($url->getPath());
486490
$body = sprintf("%s\n%d\n%s", $method, $expiry, $urlPath);
487491
$hash = hash_hmac('sha1', $body, $secret);

tests/OpenCloud/Tests/ObjectStore/Resource/DataObjectTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ public function test_temp_urls_can_be_forced_to_use_public_urls()
111111

112112
// Check that internal URLs are NOT used
113113
$this->assertNotContains('snet-storage', $tempUrl);
114+
115+
// Check that the URL contains the required file path
116+
$this->assertContains('/foo/bar', $tempUrl);
114117
}
115118

116119
public function test_Purge()

0 commit comments

Comments
 (0)