Skip to content

Commit 6b2cde9

Browse files
committed
Flysystem v3 support for s3
1 parent 0209dc2 commit 6b2cde9

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/FileVault.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public function streamDecrypt($sourceFile)
164164
protected function getFilePath($file)
165165
{
166166
if ($this->isS3File()) {
167-
return "s3://{$this->adapter->getBucket()}/{$file}";
167+
return "s3://{$this->getBucket()}/{$file}";
168168
}
169169

170170
return Storage::disk($this->disk)->path($file);
@@ -175,6 +175,11 @@ protected function isS3File()
175175
return $this->disk == 's3';
176176
}
177177

178+
protected function getBucket()
179+
{
180+
return config('filesystems.disks.s3.bucket');
181+
}
182+
178183
protected function setAdapter()
179184
{
180185
if ($this->adapter) {
@@ -189,7 +194,17 @@ protected function registerServices()
189194
$this->setAdapter();
190195

191196
if ($this->isS3File()) {
192-
$client = $this->adapter->getClient();
197+
198+
$adapter = $this->adapter;
199+
200+
if (is_a($adapter, 'League\Flysystem\AwsS3V3\AwsS3V3Adapter')) {
201+
// Flysystem v3 changed the way to retrieve the client
202+
$client = Storage::disk($this->disk)->getClient();
203+
} else {
204+
$client = $this->adapter->getClient();
205+
206+
}
207+
193208
$client->registerStreamWrapper();
194209
}
195210
}

0 commit comments

Comments
 (0)