Skip to content

Commit

Permalink
Merge pull request #653 from mediasuitenz/working
Browse files Browse the repository at this point in the history
Fix temp public URL missing file path info
  • Loading branch information
Jamie Hannaford committed Jan 20, 2016
2 parents 48bacdc + 1b57e79 commit dad7eaf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/OpenCloud/ObjectStore/Resource/DataObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,11 @@ public function getTemporaryUrl($expires, $method, $forcePublicUrl = false)
}
// @codeCoverageIgnoreEnd

$url = ($forcePublicUrl === true) ? $this->getService()->getEndpoint()->getPublicUrl() : $this->getUrl();
$url = $this->getUrl();
if ($forcePublicUrl === true) {
$url->setHost($this->getService()->getEndpoint()->getPublicUrl()->getHost());
}

$urlPath = urldecode($url->getPath());
$body = sprintf("%s\n%d\n%s", $method, $expiry, $urlPath);
$hash = hash_hmac('sha1', $body, $secret);
Expand Down
3 changes: 3 additions & 0 deletions tests/OpenCloud/Tests/ObjectStore/Resource/DataObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ public function test_temp_urls_can_be_forced_to_use_public_urls()

// Check that internal URLs are NOT used
$this->assertNotContains('snet-storage', $tempUrl);

// Check that the URL contains the required file path
$this->assertContains('/foo/bar', $tempUrl);
}

public function test_Purge()
Expand Down

0 comments on commit dad7eaf

Please sign in to comment.