Merge pull request #50514 from nextcloud/feat/s3/sse-c

feat(S3): add SSE-C support in S3 External Storage
pull/50069/head^2
Andy Scherzinger 2025-01-29 18:32:49 +07:00 committed by GitHub
commit 3f45bc5ed3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 4 deletions

@ -41,6 +41,9 @@ class AmazonS3 extends Backend {
(new DefinitionParameter('useMultipartCopy', $l->t('Enable multipart copy')))
->setType(DefinitionParameter::VALUE_BOOLEAN)
->setDefaultValue(true),
(new DefinitionParameter('sse_c_key', $l->t('SSE-C encryption key')))
->setType(DefinitionParameter::VALUE_PASSWORD)
->setFlag(DefinitionParameter::FLAG_OPTIONAL),
])
->addAuthScheme(AccessKey::SCHEME_AMAZONS3_ACCESSKEY)
->addAuthScheme(AuthMechanism::SCHEME_NULL)

@ -113,7 +113,7 @@ class AmazonS3 extends Common {
$this->objectCache[$key] = $this->getConnection()->headObject([
'Bucket' => $this->bucket,
'Key' => $key
])->toArray();
] + $this->getSSECParameters())->toArray();
} catch (S3Exception $e) {
if ($e->getStatusCode() >= 500) {
throw $e;
@ -207,7 +207,7 @@ class AmazonS3 extends Common {
'Key' => $path . '/',
'Body' => '',
'ContentType' => FileInfo::MIMETYPE_FOLDER
]);
] + $this->getSSECParameters());
$this->testTimeout();
} catch (S3Exception $e) {
$this->logger->error($e->getMessage(), [
@ -507,7 +507,7 @@ class AmazonS3 extends Common {
'Body' => '',
'ContentType' => $mimeType,
'MetadataDirective' => 'REPLACE',
]);
] + $this->getSSECParameters());
$this->testTimeout();
} catch (S3Exception $e) {
$this->logger->error($e->getMessage(), [

@ -213,7 +213,7 @@ trait S3ConnectionTrait {
}
protected function getSSECKey(): ?string {
if (isset($this->params['sse_c_key'])) {
if (isset($this->params['sse_c_key']) && !empty($this->params['sse_c_key'])) {
return $this->params['sse_c_key'];
}