diff --git a/Classes/GcsTarget.php b/Classes/GcsTarget.php index 20806bd..17b6d3f 100644 --- a/Classes/GcsTarget.php +++ b/Classes/GcsTarget.php @@ -60,6 +60,13 @@ class GcsTarget implements TargetInterface */ protected $keyPrefix = ''; + /** + * Name of the Google Cloud Storage bucket which should be used for publication + * + * @var string + */ + protected $objectVisibility = 'publicRead'; + /** * @var string */ @@ -190,6 +197,9 @@ public function __construct(string $name, array $options = []) case 'keyPrefix': $this->keyPrefix = ltrim($value, '/'); break; + case 'objectVisibility': + $this->objectVisibility = $value; + break; case 'persistentResourceUris': if (!is_array($value)) { throw new Exception(sprintf('The option "%s" which was specified in the configuration of the "%s" resource GcsTarget is not a valid array. Please check your settings.', $key, $name), 1568875196); @@ -399,7 +409,7 @@ private function publishCollectionFromDifferentGoogleCloudStorage(CollectionInte $this->logger->debug(sprintf('Copy object "%s" to bucket "%s"', $targetObjectName, $this->bucketName), LogEnvironment::fromMethodName(__METHOD__)); $options = [ 'name' => $targetObjectName, - 'predefinedAcl' => 'publicRead', + 'predefinedAcl' => $this->objectVisibility, 'contentType' => $object->getMediaType(), 'cacheControl' => 'public, max-age=1209600', ]; @@ -465,7 +475,7 @@ public function publishResource(PersistentResource $resource, CollectionInterfac $storageBucket = $this->storageClient->bucket($storage->getBucketName()); $storageBucket->object($storage->getKeyPrefix() . $resource->getSha1())->update( [ - 'predefinedAcl' => 'publicRead', + 'predefinedAcl' => $this->objectVisibility, 'contentType' => $resource->getMediaType(), 'cacheControl' => 'public, max-age=1209600' ]); @@ -491,7 +501,7 @@ public function publishResource(PersistentResource $resource, CollectionInterfac try { $storageBucket->object($storage->getKeyPrefix() . $resource->getSha1())->copy($this->getCurrentBucket(), [ 'name' => $targetObjectName, - 'predefinedAcl' => 'publicRead', + 'predefinedAcl' => $this->objectVisibility, 'contentType' => $resource->getMediaType(), 'cacheControl' => 'public, max-age=1209600', ]); @@ -598,7 +608,7 @@ protected function publishFile($sourceStream, string $relativeTargetPathAndFilen $objectName = $this->keyPrefix . $relativeTargetPathAndFilename; $uploadParameters = [ 'name' => $objectName, - 'predefinedAcl' => 'publicRead', + 'predefinedAcl' => $this->objectVisibility, 'contentType' => $metaData->getMediaType(), 'cacheControl' => 'public, max-age=1209600' ];