From 98caeb6c65b2a0a172e12f0d8673c7d62509ef1b Mon Sep 17 00:00:00 2001 From: Martin Zurowietz Date: Tue, 8 Feb 2022 11:58:29 +0100 Subject: [PATCH] Make the adapter implement CanOverwriteFiles Files can be overwritten with Swift (as update does the same than write) and implementing the interface will save HTTP requests during put and putStream. --- src/SwiftAdapter.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/SwiftAdapter.php b/src/SwiftAdapter.php index fc6bc24..fce62a7 100644 --- a/src/SwiftAdapter.php +++ b/src/SwiftAdapter.php @@ -4,16 +4,17 @@ use GuzzleHttp\Psr7\Stream; use GuzzleHttp\Psr7\StreamWrapper; -use League\Flysystem\Util; -use League\Flysystem\Config; use League\Flysystem\Adapter\AbstractAdapter; +use League\Flysystem\Adapter\CanOverwriteFiles; +use League\Flysystem\Adapter\Polyfill\NotSupportingVisibilityTrait; +use League\Flysystem\Adapter\Polyfill\StreamedCopyTrait; +use League\Flysystem\Config; +use League\Flysystem\Util; use OpenStack\Common\Error\BadResponseError; use OpenStack\ObjectStore\v1\Models\Container; use OpenStack\ObjectStore\v1\Models\StorageObject; -use League\Flysystem\Adapter\Polyfill\NotSupportingVisibilityTrait; -use League\Flysystem\Adapter\Polyfill\StreamedCopyTrait; -class SwiftAdapter extends AbstractAdapter +class SwiftAdapter extends AbstractAdapter implements CanOverwriteFiles { use StreamedCopyTrait; use NotSupportingVisibilityTrait; @@ -87,7 +88,7 @@ public function update($path, $contents, Config $config) */ public function updateStream($path, $resource, Config $config) { - return $this->write($path, new Stream($resource), $config, Util::getStreamSize($resource)); + return $this->writeStream($path, $resource, $config); } /**