Skip to content

Commit

Permalink
Make the adapter implement CanOverwriteFiles
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mzur committed Feb 8, 2022
1 parent 99ef0d7 commit 98caeb6
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/SwiftAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 98caeb6

Please sign in to comment.