Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 how to add prefix to S3 file storage config?

In the config/filesytems.php, the default settings is like this

's3' => [
    'driver' => 's3',
    'key' => env('AWS_ACCESS_KEY_ID'),
    'secret' => env('AWS_SECRET_ACCESS_KEY'),
    'region' => env('AWS_DEFAULT_REGION'),
    'bucket' => env('AWS_BUCKET'),
    'url' => env('AWS_URL'),
],

Now, in development, there's only 1 bucket shared by all developers.

Is it possible to add a prefix (as a subfolder) to the config file?

For example

's3' => [
    ...
    'prefix' => 'jslim/',
],

How can I achieve this?

like image 266
Js Lim Avatar asked Sep 27 '18 07:09

Js Lim


1 Answers

The configuration option you're looking for is called root:

'disks' => [
    's3' => [
        'root' => 'jslim/',
        // 'root' => env('S3_PREFIX', env('APP_ENV') . '/'),
    ],
],

Hope that helps.

like image 123
Till Avatar answered Nov 01 '22 03:11

Till