-
-
Save mhemrg/76a0454ccc07f700a035f039834e29b0 to your computer and use it in GitHub Desktop.
Using S3 client directly in Laravel | Copy file between buckets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** @var \Illuminate\Filesystem\FilesystemAdapter $fs */ | |
$fs = \Storage::disk('liara'); | |
/** @var \League\Flysystem\Filesystem $driver */ | |
$driver = $fs->getDriver(); | |
/** @var \League\Flysystem\AwsS3v3\AwsS3Adapter $adapter */ | |
$adapter = $driver->getAdapter(); | |
/** @var \Aws\S3\S3Client $client */ | |
$client = $adapter->getClient(); | |
try { | |
$client->copy( | |
'bucket1', | |
'current_name', | |
'bucket2', | |
'new_name', | |
'private', | |
$this->options | |
); | |
} catch (\Aws\S3\Exception\S3Exception $e) { | |
// handle exception | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment