-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using more than one set of credentials or storage locations s3 compatible #39
Comments
If you have two different clients: $s3Client = new Aws\S3\S3Client([
// ...
]);
$minioClient = new Aws\S3\S3Client([
// ...
]); You can set the client on each individual file if you make it yourself: use Zip;
use STS\ZipStream\Models\File;
$zip = Zip::create("download.zip")
->add(File::make("s3://path/to/file.txt")->setS3Client($s3Client))
->add(File::make("s3://path/to/another.txt")->setS3Client($minioClient)); Note the method here: https://github.com/stechstudio/laravel-zipstream/blob/master/src/Models/S3File.php#L35 Of course this assumes you even know which client to use at this point. I suppose you could even stick a conditional in there: $zip = Zip::create("download.zip")
->add(File::make("s3://path/to/file.txt")->setS3Client(
$s3Client->doesObjectExist("bucket", "file.txt") ? $s3Client : $minioClient
)) That's all untested of course, but something along these lines should work. Alternatively you could extend the S3File model and add custom logic in the class MyCloudFile extends S3File {
public function getS3Client(): S3Client
{
// This assumes you have your two clients bound in the container
return app('s3Client')->doesObjectExist($this->getBucket(), $this->getKey())
? app('s3Client')
: app('minioClient');
}
} Then you need to make this file explicitly: Zip::create("download.zip")
->add(MyCloudFile::make("s3://path/to/file.txt")); Hope that helps! |
This was the secret sauce here:
Works perfectly, thank you! |
First, thank you for this git, it works perfect when pulling data from an s3 location.
I've been hacking the config and stream files to work in the following situation:
The idea is that s3 if first checked with a try and catch exception then goes to the Minio file.
My only issue, is should I run a composer update, will I break my setup?
What do you suggest is the best way to pass the creds variables to be used in the Zip::create so that they are not broken on a future update?
Thanks!
The text was updated successfully, but these errors were encountered: