Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions Classes/GcsTarget.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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',
];
Expand Down Expand Up @@ -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'
]);
Expand All @@ -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',
]);
Expand Down Expand Up @@ -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'
];
Expand Down