phplaravelamazon-s3laravel-filesystem

Can S3 Laravel Disk be pointed at a specific folder within a bucket


In Laravel filesystems you have the standard s3 details like below:

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

What I am trying to establish is having 2 disks listed in my filesystems, one that points at a directory on my bucket that is public and another disk that points somewhere private.

I'm looking for something like:

root_path => '/public'

Solution

  • use can use something like this

        's3-public' => [
            'driver' => 's3',
            'key' => env('AWS_ACCESS_KEY_ID', 'your-key'),
            'secret' => env('AWS_SECRET_ACCESS_KEY', 'your-secret'),
            'region' => env('AWS_DEFAULT_REGION', 'your-region'),
            'bucket' => env('AWS_BUCKET', 'your-bucket'),
            'url' => env('AWS_URL'),
            'endpoint' => env('AWS_ENDPOINT'),
            'root' => 'test/public'
        ],
    
    
        's3-private' => [
            'driver' => 's3',
            'key' => env('AWS_ACCESS_KEY_ID', 'your-key'),
            'secret' => env('AWS_SECRET_ACCESS_KEY', 'your-secret'),
            'region' => env('AWS_DEFAULT_REGION', 'your-region'),
            'bucket' => env('AWS_BUCKET', 'your-bucket'),
            'url' => env('AWS_URL'),
            'endpoint' => env('AWS_ENDPOINT'),
            'root' => 'test/private'
        ],
    

    you can use same bucket for this two disks but files save to different folder