S3 Uploads Not working

Hello,

I have setup s3 uploads from the article

https://docs.octobercms.com/3.x/cms/media/providers.html#local-disk

The system.php is

    'storage' => [
        'media' => [
            'disk'   => 's3',
            'folder' => 'media',
            'path'   => 'https://s3.eu-central-1.amazonaws.com/*******/media',
        ],
    ],

The filesystems.php is

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Default Filesystem Disk
    |--------------------------------------------------------------------------
    |
    | Here you may specify the default filesystem disk that should be used
    | by the framework. A "local" driver, as well as a variety of cloud
    | based drivers are available for your choosing. Just store away!
    |
    */

    'default' => 's3',

    /*
    |--------------------------------------------------------------------------
    | Filesystem Disks
    |--------------------------------------------------------------------------
    |
    | Here you may configure as many filesystem "disks" as you wish, and you
    | may even configure multiple disks of the same driver. Defaults have
    | been setup for each driver as an example of the required options.
    |
    | Supported Drivers: "local", "ftp", "sftp", "s3"
    |
    */

    'disks' => [

        'local' => [
            'driver' => 'local',
            'root' => storage_path('app'),
            'throw' => false,
        ],

        'uploads' => [
            'driver' => 's3',
            'key'    => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
            'region' => env('AWS_DEFAULT_REGION'),
            'bucket' => env('AWS_BUCKET'),
            'url' => 'https://s3.eu-central-1.amazonaws.com/***/uploads',
            'visibility' => 'public',
            'throw' => false
        ],

        'media' => [
            'driver' => 's3',
            'key'    => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
            'region' => env('AWS_DEFAULT_REGION'),
            'bucket' => env('AWS_BUCKET'),
            'url' => 'https://s3.eu-central-1.amazonaws.com/****/media',
            'visibility' => 'public',
            'throw' => false
        ],

        'resources' => [
            'driver' => 'local',
            'root' => storage_path('app/resources'),
            'url' => '/storage/app/resources',
            'visibility' => 'public',
            'throw' => false,
        ],

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

    ],

];

The media folder works. BUT the uploads is not working. everytime i upload something it adds a public folder in media.

Any direction would be very helpful.

Thanks alot.

Hey,

if you using S3 you need to set root directory, per every filesystem disks separately.

1 Like

@Samuell can you explain it a bit more.

The root key determines a folder inside the storage disk, so you can use the same storage disk for multiple resources.

1 Like

@daft thanks.

Can you show me an example?

    'storage' => [
        'media' => [
            'disk'   => 's3',
            'root' => 'media',
        ],
    ],