Skip to content

Commit

Permalink
Conflict resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
TSI-kavitasonawane committed Aug 30, 2021
1 parent 8a86079 commit 96e4058
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 146 deletions.
119 changes: 0 additions & 119 deletions lib/private/Files/ObjectStore/S3ConnectionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,127 +90,8 @@ public function getBucket() {
return $this->bucket;
}

<<<<<<< HEAD
public function getProxy() {
return $this->proxy;
=======
/**
* Add the SSE KMS parameterdepending on the
* KMS encryption strategy (bucket, individual or
* no encryption) for object creations.
*
* @return array with encryption parameters
*/
public function getSseKmsPutParameters(): array {
if (!empty($this->sseKmsBucketKeyId)) {
return [
'ServerSideEncryption' => 'aws:kms',
];
} elseif (!empty($this->sseKmsKeyId)) {
return [
'ServerSideEncryption' => 'aws:kms',
'SSEKMSKeyId' => $this->sseKmsKeyId,
];
} else {
return [];
}
}

/**
* Add the SSE KMS parameter depending on the
* KMS encryption strategy (bucket, individual or
* no encryption) for object read.
*
* @return array with encryption parameters
*/
public function getSseKmsGetParameters(): array {
if (!empty($this->sseKmsBucketKeyId)) {
return [
'ServerSideEncryption' => 'aws:kms',
'SSEKMSKeyId' => $this->sseKmsBucketKeyId,
];
} elseif (!empty($this->sseKmsKeyId)) {
return [
'ServerSideEncryption' => 'aws:kms',
'SSEKMSKeyId' => $this->sseKmsKeyId,
];
} else {
return [];
}
}


/**
* Create the required bucket
*
* @throws \Exception if bucket creation fails
*/
protected function createNewBucket() {
$logger = \OC::$server->getLogger();
try {
$logger->info('Bucket "'.$this->bucket.'" does not exist - creating it.', ['app' => 'objectstore']);
if (!$this->connection::isBucketDnsCompatible($this->bucket)) {
throw new \Exception('The bucket will not be created because the name is not dns compatible, please correct it: '.$this->bucket);
}
$this->connection->createBucket(['Bucket' => $this->bucket]);
$this->testTimeout();
} catch (S3Exception $e) {
$logger->logException($e, [
'message' => 'Invalid remote storage.',
'level' => ILogger::DEBUG,
'app' => 'objectstore',
]);
throw new \Exception('Creation of bucket "'.$this->bucket.'" failed. '.$e->getMessage());
}
}

/**
* Check bucket key consistency or put bucket key if missing
* This operation only works for bucket owner or with
* s3:GetEncryptionConfiguration/s3:PutEncryptionConfiguration permission
*
* We recommend to use autocreate only on initial setup and
* use an S3:user only with object operation permission and no bucket operation permissions
* later with autocreate=false
*
* @throws \Exception if bucket key config is inconsistent or if putting the key fails
*/
protected function checkOrPutBucketKey() {
$logger = \OC::$server->getLogger();

try {
$encrypt_state = $this->connection->getBucketEncryption([
'Bucket' => $this->bucket,
]);
return;
} catch (S3Exception $e) {
try {
$logger->info('Bucket key for "'.$this->bucket.'" is not set - adding it.', ['app' => 'objectstore']);
$this->connection->putBucketEncryption([
'Bucket' => $this->bucket ,
'ServerSideEncryptionConfiguration' => [
'Rules' => [
[
'ApplyServerSideEncryptionByDefault' => [
'KMSMasterKeyID' => $this->sseKmsBucketKeyId,
'SSEAlgorithm' => 'aws:kms',
],
'BucketKeyEnabled' => true,
],
],
],
]);
$this->testTimeout();
} catch (S3Exception $e) {
$logger->logException($e, [
'message' => 'Bucket key problem.',
'level' => ILogger::DEBUG,
'app' => 'objectstore',
]);
throw new \Exception('Putting configured bucket key to "'.$this->bucket.'" failed. '.$e->getMessage());
}
}
>>>>>>> Fix small syntax problem
}

/**
Expand Down
27 changes: 0 additions & 27 deletions lib/private/Files/ObjectStore/S3ObjectTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public function readObject($urn) {
}

/**
<<<<<<< HEAD
* Single object put helper
*
* @param string $urn the unified resource name used to identify the object
Expand All @@ -99,19 +98,6 @@ protected function writeSingle(string $urn, StreamInterface $stream, string $mim
]);
}

=======
* @param string $urn the unified resource name used to identify the object
* @param resource $stream stream with the data to write
* @param string|null $mimetype the mimetype to set for the remove object @since 22.0.0
* @throws \Exception when something goes wrong, message will be logged
* @since 7.0.0
*/
public function writeObject($urn, $stream, string $mimetype = null) {
$count = 0;
$countStream = CallbackWrapper::wrap($stream, function ($read) use (&$count) {
$count += $read;
});
>>>>>>> Keep miemtype handling for writeObject

/**
* Multipart upload helper that tries to avoid orphaned fragments in S3
Expand All @@ -128,14 +114,8 @@ protected function writeMultiPart(string $urn, StreamInterface $stream, string $
'part_size' => $this->uploadPartSize,
'params' => [
'ContentType' => $mimetype
<<<<<<< HEAD
],
]);
=======
] + $this->getSseKmsPutParameters(),
];
$uploader = new MultipartUploader($this->getConnection(), $countStream, $s3params);
>>>>>>> Keep miemtype handling for writeObject

try {
$uploader->upload();
Expand Down Expand Up @@ -191,14 +171,7 @@ public function deleteObject($urn) {
public function objectExists($urn) {
return $this->getConnection()->doesObjectExist($this->bucket, $urn);
}
<<<<<<< HEAD

=======

/**
* S3 copy command with SSE KMS key handling.
*/
>>>>>>> Keep miemtype handling for writeObject
public function copyObject($from, $to) {
$this->getConnection()->copy($this->getBucket(), $from, $this->getBucket(), $to);
}
Expand Down

0 comments on commit 96e4058

Please sign in to comment.