Merge pull request #36075 from fmenabe/s3-storage-class

Add support for s3 storage classes
pull/36159/head
Côme Chilliet 1 year ago committed by GitHub
commit 5e090d044d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -47,6 +47,8 @@ class AmazonS3 extends Backend {
->setFlag(DefinitionParameter::FLAG_OPTIONAL),
(new DefinitionParameter('region', $l->t('Region')))
->setFlag(DefinitionParameter::FLAG_OPTIONAL),
(new DefinitionParameter('storageClass', $l->t('Storage Class')))
->setFlag(DefinitionParameter::FLAG_OPTIONAL),
(new DefinitionParameter('use_ssl', $l->t('Enable SSL')))
->setType(DefinitionParameter::VALUE_BOOLEAN),
(new DefinitionParameter('use_path_style', $l->t('Enable Path Style')))

@ -583,7 +583,8 @@ class AmazonS3 extends \OC\Files\Storage\Common {
$this->getConnection()->copyObject([
'Bucket' => $this->bucket,
'Key' => $this->cleanKey($target),
'CopySource' => S3Client::encodeKey($this->bucket . '/' . $source)
'CopySource' => S3Client::encodeKey($this->bucket . '/' . $source),
'StorageClass' => $this->storageClass,
]);
$this->testTimeout();
} catch (S3Exception $e) {

@ -62,6 +62,9 @@ trait S3ConnectionTrait {
/** @var string */
protected $proxy;
/** @var string */
protected $storageClass;
/** @var int */
protected $uploadPartSize;
@ -81,6 +84,7 @@ trait S3ConnectionTrait {
$this->bucket = $params['bucket'];
$this->proxy = $params['proxy'] ?? false;
$this->timeout = $params['timeout'] ?? 15;
$this->storageClass = !empty($params['storageClass']) ? $params['storageClass'] : 'STANDARD';
$this->uploadPartSize = $params['uploadPartSize'] ?? 524288000;
$this->putSizeLimit = $params['putSizeLimit'] ?? 104857600;
$params['region'] = empty($params['region']) ? 'eu-west-1' : $params['region'];

@ -105,6 +105,7 @@ trait S3ObjectTrait {
'Body' => $stream,
'ACL' => 'private',
'ContentType' => $mimetype,
'StorageClass' => $this->storageClass,
]);
}
@ -123,7 +124,8 @@ trait S3ObjectTrait {
'key' => $urn,
'part_size' => $this->uploadPartSize,
'params' => [
'ContentType' => $mimetype
'ContentType' => $mimetype,
'StorageClass' => $this->storageClass,
],
]);

Loading…
Cancel
Save