Skip to content

Commit

Permalink
Merge pull request #15 from gromaco/master
Browse files Browse the repository at this point in the history
BUGFIX: Filenames need to be rawurlencoded
  • Loading branch information
kdambekalns authored Jan 10, 2018
2 parents 1a1f285 + b627a9b commit 62fd5a9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Classes/S3Target.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,23 @@ public function unpublishResource(PersistentResource $resource)
public function getPublicPersistentResourceUri(PersistentResource $resource)
{
if ($this->baseUri != '') {
return $this->baseUri . $this->getRelativePublicationPathAndFilename($resource);
return $this->baseUri . $this->encodeRelativePathAndFilenameForUri($this->getRelativePublicationPathAndFilename($resource));
} else {
return $this->s3Client->getObjectUrl($this->bucketName, $this->keyPrefix . $this->getRelativePublicationPathAndFilename($resource));
}
}

/**
* Applies rawurlencode() to all path segments of the given $relativePathAndFilename
*
* @param string $relativePathAndFilename
* @return string
*/
protected function encodeRelativePathAndFilenameForUri($relativePathAndFilename)
{
return implode('/', array_map('rawurlencode', explode('/', $relativePathAndFilename)));
}

/**
* Publishes the specified source file to this target, with the given relative path.
*
Expand Down

0 comments on commit 62fd5a9

Please sign in to comment.