diff --git a/Classes/S3Target.php b/Classes/S3Target.php index 4772ad3..6bcc1da 100644 --- a/Classes/S3Target.php +++ b/Classes/S3Target.php @@ -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. *