Last active
March 26, 2020 02:43
-
-
Save JacobBennett/d64d08c5638e84d0dfafc38139726b51 to your computer and use it in GitHub Desktop.
Revisions
-
JacobBennett renamed this gist
Mar 26, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
JacobBennett revised this gist
Mar 26, 2020 . 1 changed file with 25 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ <?php namespace App\Wilber\MediaLibrary\UrlGenerator; use Illuminate\Contracts\Config\Repository as Config; use Illuminate\Filesystem\FilesystemManager; use Spatie\MediaLibrary\UrlGenerator\S3UrlGenerator; class S3SwapUrlGenerator extends S3UrlGenerator { public function __construct(Config $config, FilesystemManager $filesystemManager) { parent::__construct($config, $filesystemManager); } public function getUrl(): string { if (! app()->environment('production')) { // minio url return config('medialibrary.minio.local.domain').'/'.$this->getPathRelativeToRoot(); } return config('medialibrary.s3.domain').'/'.$this->getPathRelativeToRoot(); } } -
JacobBennett revised this gist
Mar 26, 2020 . 1 changed file with 32 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ <?php namespace App\Providers; use Illuminate\Support\Arr; use Illuminate\Support\Facades\Storage; use Illuminate\Support\ServiceProvider; class SwapDriverServiceProvider extends ServiceProvider { /** * Bootstrap services. * * @return void */ public function boot() { Storage::extend('s3-swap', function ($app, $config) { return Storage::createS3Driver($this->getConfig($app, $config)); }); } public function getConfig($app, $config) { return ! $app->environment('production') ? $config : Arr::except($config, [ 'endpoint', 'use_path_style_endpoint', ]); } } -
JacobBennett revised this gist
Mar 26, 2020 . 1 changed file with 18 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ <?php return [ 'disks' => [ 's3' => [ 'driver' => 's3-swap', 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 'bucket' => env('AWS_BUCKET', 'wilberpay.com'), 'url' => env('AWS_URL'), // local use 'endpoint' => env('MINIO_ENDPOINT'), 'use_path_style_endpoint' => true, ], ] ]; -
JacobBennett created this gist
Mar 26, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ # Filesystem Decision Tree ## Filesystem Driver ### S3 BUCKET IN PRODUCTION - How to use: - Use s3-swap driver and use minio for local development - Use Storage fake for tests - when to use: - backups - uploaded files or documents storage (images, pdfs) - generated files or documents storage ### MINIO IN PRODUCTION - How to use: - Use s3 driver and use minio for local development - Use Storage fake for tests - When to use: - Other internal, non-PHP processes need to be able to write to location - Convenient to access with Windows file explorer UI - Files will only be used internally ### LOCAL IN PRODUCTION - How to use: - use local driver - Use Storage fake for tests. - When to use: - Files are present that we want in version control - Files that will change infrequently enough to justify being part of the repo - NON user uploaded files - Think "fixtures" ## Filesystem Access Keys Each application should have a single set of credentials per driver. The only exception to this would be if you were using multiple minio drives.