Skip to content

Commit

Permalink
Merge branch '1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
robertlemke committed Mar 14, 2017
2 parents abc9c37 + 5f8669e commit c326dda
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
3 changes: 2 additions & 1 deletion Classes/Command/GcsCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public function connectCommand($bucket)

$postBody = [
'data' => 'test',
'uploadType' => 'media'
'uploadType' => 'media',
'mimeType' => 'text/plain'
];

$this->outputLine('Writing test object into bucket (%s) ...', [$bucket]);
Expand Down
8 changes: 5 additions & 3 deletions Classes/GcsStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ public function importResourceFromContent($content, $collectionName)
$storageObject->setName($this->keyPrefix . $sha1Hash);
$storageObject->setSize($resource->getFileSize());

$this->storageService->objects->insert($this->bucketName, $storageObject, ['data' => $content, 'uploadType' => 'media']);
$this->storageService->objects->insert($this->bucketName, $storageObject,
['data' => $content, 'uploadType' => 'media', 'mimeType' => $resource->getMediaType()]);

return $resource;
}
Expand Down Expand Up @@ -270,7 +271,8 @@ public function importUploadedResource(array $uploadInfo, $collectionName)

$postBody = [
'data' => file_get_contents($newSourcePathAndFilename),
'uploadType' => 'media'
'uploadType' => 'media',
'mimeType' => $resource->getMediaType()
];

$this->storageService->objects->insert($this->bucketName, $storageObject, $postBody);
Expand Down Expand Up @@ -447,7 +449,7 @@ protected function importTemporaryFile($temporaryPathAndFilename, $collectionNam
$storageObject->setName($this->keyPrefix . $sha1Hash);
$storageObject->setSize($resource->getFileSize());

$this->storageService->objects->insert($this->bucketName, $storageObject, ['data' => file_get_contents($temporaryPathAndFilename), 'uploadType' => 'media']);
$this->storageService->objects->insert($this->bucketName, $storageObject, ['data' => file_get_contents($temporaryPathAndFilename), 'uploadType' => 'media', 'mimeType' => $resource->getMediaType()]);
$this->systemLogger->log(sprintf('Successfully imported resource as object "%s" into bucket "%s" with MD5 hash "%s"', $sha1Hash, $this->bucketName, $resource->getMd5() ?: 'unknown'), LOG_INFO);
} else {
$this->systemLogger->log(sprintf('Did not import resource as object "%s" into bucket "%s" because that object already existed.', $sha1Hash, $this->bucketName), LOG_INFO);
Expand Down
9 changes: 6 additions & 3 deletions Classes/GcsTarget.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ public function publishCollection(CollectionInterface $collection)
$storageObject->setCacheControl('public, max-age=1209600');

$parameters = [
'destinationPredefinedAcl' => 'publicRead'
'destinationPredefinedAcl' => 'publicRead',
'mimeType' => $object->getMediaType()
];
try {
$this->storageService->objects->copy($storageBucketName, $storage->getKeyPrefix() . $object->getSha1(), $this->bucketName, $objectName, $storageObject, $parameters);
Expand Down Expand Up @@ -268,7 +269,8 @@ public function publishResource(PersistentResource $resource, CollectionInterfac
$storageObject->setCacheControl('public, max-age=1209600');

$parameters = [
'destinationPredefinedAcl' => 'publicRead'
'destinationPredefinedAcl' => 'publicRead',
'mimeType' => $resource->getMediaType()
];
try {
$this->storageService->objects->copy($storage->getBucketName(), $storage->getKeyPrefix() . $resource->getSha1(), $this->bucketName, $objectName, $storageObject, $parameters);
Expand Down Expand Up @@ -345,7 +347,8 @@ protected function publishFile($sourceStream, $relativeTargetPathAndFilename, Re
$parameters = [
'data' => stream_get_contents($sourceStream),
'uploadType' => 'media',
'predefinedAcl' => 'publicRead'
'predefinedAcl' => 'publicRead',
'mimeType' => $metaData->getMediaType()
];

$this->storageService->objects->insert($this->bucketName, $storageObject, $parameters);
Expand Down

0 comments on commit c326dda

Please sign in to comment.