Skip to content

Commit

Permalink
feat: add a specialized writeStream implementation for s3 external st…
Browse files Browse the repository at this point in the history
…orage

Signed-off-by: Robin Appelman <robin@icewind.nl>
  • Loading branch information
icewind1991 committed Jul 22, 2024
1 parent 8cc9961 commit 0bea0f2
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions apps/files_external/lib/Lib/Storage/AmazonS3.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

use Aws\S3\Exception\S3Exception;
use Icewind\Streams\CallbackWrapper;
use Icewind\Streams\CountWrapper;
use Icewind\Streams\IteratorDirectory;
use OC\Files\Cache\CacheEntry;
use OC\Files\ObjectStore\S3ConnectionTrait;
Expand Down Expand Up @@ -754,4 +755,18 @@ public function hasUpdated($path, $time) {
return true;
}
}

public function writeStream(string $path, $stream, ?int $size = null): int {
if ($size === null) {
$stream = CountWrapper::wrap($stream, function ($writtenSize) use (&$size) {

Check notice

Code scanning / Psalm

MissingClosureParamType Note

Parameter $writtenSize has no provided type
$size = $writtenSize;
});
}

$path = $this->normalizePath($path);
$this->writeObject($path, $stream, $this->mimeDetector->detectPath($path));

Check notice

Code scanning / Psalm

PossiblyFalseArgument Note

Argument 2 of OCA\Files_External\Lib\Storage\AmazonS3::writeObject cannot be false, possibly resource value expected
$this->invalidateCache($path);

return $size;
}
}

0 comments on commit 0bea0f2

Please sign in to comment.