Dynamically change Azure Container
skeetyeet opened this issue · 3 comments
Hi,
Thank you so much for creating this. I love it!
I am new to laravel so I might have missed it but is there a way to select a different Container to upload to during run time?
It should be possible. The example configuration in the README.md
is nothing more than a PHP array, and while it populates it from environment variables (either ones set by the web server or in the .env
file), there's no reason why that has to be the case - you could populate it dynamically.
Another alternative is to set up several different filesystems in the same file. Calling them azure
in the example is not required (only the driver needs to be set to this), so you could do something like this:
'azure1' => [
'driver' => 'azure',
'name' => env('AZURE_STORAGE_NAME_1'),
'key' => env('AZURE_STORAGE_KEY_1'),
'container' => env('AZURE_STORAGE_CONTAINER_1'),
'url' => env('AZURE_STORAGE_URL_1'),
'prefix' => null,
],
'azure2' => [
'driver' => 'azure',
'name' => env('AZURE_STORAGE_NAME_2'),
'key' => env('AZURE_STORAGE_KEY_2'),
'container' => env('AZURE_STORAGE_CONTAINER_2'),
'url' => env('AZURE_STORAGE_URL_2'),
'prefix' => null,
],
Then just choose the filesystems as you need them, as described in the Laravel docs for the file storage.
Does that answer your question?
That's perfect Matthew! Don't know why I didn't think of that. Thanks so much.
It should be possible. The example configuration in the
README.md
is nothing more than a PHP array, and while it populates it from environment variables (either ones set by the web server or in the.env
file), there's no reason why that has to be the case - you could populate it dynamically.Another alternative is to set up several different filesystems in the same file. Calling them
azure
in the example is not required (only the driver needs to be set to this), so you could do something like this:'azure1' => [ 'driver' => 'azure', 'name' => env('AZURE_STORAGE_NAME_1'), 'key' => env('AZURE_STORAGE_KEY_1'), 'container' => env('AZURE_STORAGE_CONTAINER_1'), 'url' => env('AZURE_STORAGE_URL_1'), 'prefix' => null, ], 'azure2' => [ 'driver' => 'azure', 'name' => env('AZURE_STORAGE_NAME_2'), 'key' => env('AZURE_STORAGE_KEY_2'), 'container' => env('AZURE_STORAGE_CONTAINER_2'), 'url' => env('AZURE_STORAGE_URL_2'), 'prefix' => null, ],
Then just choose the filesystems as you need them, as described in the Laravel docs for the file storage.
Does that answer your question?
this method is better way to upload to multiple container when changing container dynamically it won't work quickly