Experiment with ObjectUploader

Signed-off-by: Bernd.Rederlechner@t-systems.com <bernd.rederlechner@t-systems.com>
This commit is contained in:
Bernd.Rederlechner@t-systems.com 2021-05-27 14:11:53 +00:00
parent 2805536f7d
commit 1b19e0ebbf
1 changed files with 2 additions and 15 deletions

View File

@ -101,8 +101,6 @@ trait S3ObjectTrait
}); });
$s3params = [ $s3params = [
'bucket' => $this->bucket,
'key' => $urn,
'part_size' => $this->uploadPartSize, 'part_size' => $this->uploadPartSize,
'params' => [ 'params' => [
'ContentType' => $mimetype 'ContentType' => $mimetype
@ -111,25 +109,14 @@ trait S3ObjectTrait
// maybe, we should also use ObjectUploader here in the future // maybe, we should also use ObjectUploader here in the future
// it does direct uploads for small files < 5MB and multipart otherwise // it does direct uploads for small files < 5MB and multipart otherwise
// $uploader = new ObjectUploader($this->getConnection(), $this->bucket, $urn, $countStream, 'private', $s3params); $uploader = new ObjectUploader($this->getConnection(), $this->bucket, $urn, $countStream, 'private', $s3params);
$uploader = new MultipartUploader($this->getConnection(), $countStream, $s3params);
try { try {
$uploader->upload(); $uploader->upload();
} catch (S3MultipartUploadException $e) { } catch (S3MultipartUploadException $e) {
// if anything goes wrong with multipart, make sure that you don´t poison s3 bucket with fragments // if anything goes wrong with multipart, make sure that you don´t poison s3 bucket with fragments
$this->getConnection()->abortMultipartUpload($uploader->getState()->getId()); $this->getConnection()->abortMultipartUpload($uploader->getState()->getId());
if ($count === 0 && feof($countStream)) {
// This is an empty file case, so just touch it
$s3params = [
'params' => $this->getSseKmsPutParameters(),
];
$uploader = new ObjectUploader($this->getConnection(), $this->bucket, $urn, '', 'private', $s3params);
$uploader->upload();
} else {
throw $e; throw $e;
}
} finally { } finally {
// this handles [S3] fclose(): supplied resource is not a valid stream resource #23373 // this handles [S3] fclose(): supplied resource is not a valid stream resource #23373
// see https://stackoverflow.com/questions/11247507/fclose-18-is-not-a-valid-stream-resource/11247555 // see https://stackoverflow.com/questions/11247507/fclose-18-is-not-a-valid-stream-resource/11247555