Upload part size as S3 parameter instead of constant value
Some S3 providers need a custom upload part size (500 MB static value in Nextcloud). Here is a commit to change this value via S3 configuration, instead of using S3_UPLOAD_PART_SIZE constant. A new parameter is added for an S3 connection : uploadPartSize Signed-off-by: Florent <florent@coppint.com>
This commit is contained in:
parent
d6923b4bb5
commit
6280d09765
|
@ -47,6 +47,9 @@ trait S3ConnectionTrait {
|
||||||
|
|
||||||
/** @var int */
|
/** @var int */
|
||||||
protected $timeout;
|
protected $timeout;
|
||||||
|
|
||||||
|
/** @var int */
|
||||||
|
protected $uploadPartSize;
|
||||||
|
|
||||||
protected $test;
|
protected $test;
|
||||||
|
|
||||||
|
@ -60,6 +63,7 @@ trait S3ConnectionTrait {
|
||||||
$this->test = isset($params['test']);
|
$this->test = isset($params['test']);
|
||||||
$this->bucket = $params['bucket'];
|
$this->bucket = $params['bucket'];
|
||||||
$this->timeout = !isset($params['timeout']) ? 15 : $params['timeout'];
|
$this->timeout = !isset($params['timeout']) ? 15 : $params['timeout'];
|
||||||
|
$this->uploadPartSize = !isset($params['uploadPartSize']) ? 524288000 : $params['uploadPartSize'];
|
||||||
$params['region'] = empty($params['region']) ? 'eu-west-1' : $params['region'];
|
$params['region'] = empty($params['region']) ? 'eu-west-1' : $params['region'];
|
||||||
$params['hostname'] = empty($params['hostname']) ? 's3.' . $params['region'] . '.amazonaws.com' : $params['hostname'];
|
$params['hostname'] = empty($params['hostname']) ? 's3.' . $params['region'] . '.amazonaws.com' : $params['hostname'];
|
||||||
if (!isset($params['port']) || $params['port'] === '') {
|
if (!isset($params['port']) || $params['port'] === '') {
|
||||||
|
|
|
@ -33,8 +33,6 @@ use Aws\S3\S3Client;
|
||||||
use Icewind\Streams\CallbackWrapper;
|
use Icewind\Streams\CallbackWrapper;
|
||||||
use OC\Files\Stream\SeekableHttpStream;
|
use OC\Files\Stream\SeekableHttpStream;
|
||||||
|
|
||||||
const S3_UPLOAD_PART_SIZE = 524288000; // 500MB
|
|
||||||
|
|
||||||
trait S3ObjectTrait {
|
trait S3ObjectTrait {
|
||||||
/**
|
/**
|
||||||
* Returns the connection
|
* Returns the connection
|
||||||
|
@ -91,7 +89,7 @@ trait S3ObjectTrait {
|
||||||
$uploader = new MultipartUploader($this->getConnection(), $countStream, [
|
$uploader = new MultipartUploader($this->getConnection(), $countStream, [
|
||||||
'bucket' => $this->bucket,
|
'bucket' => $this->bucket,
|
||||||
'key' => $urn,
|
'key' => $urn,
|
||||||
'part_size' => S3_UPLOAD_PART_SIZE,
|
'part_size' => $this->uploadPartSize,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue