Storage uses local instead of s3

Hi everyone,

I’m trying to upgrade from 2.x to 3.x. Now I’m trying to configure October to use S3 as shown below but the images in the view are rendered using the local storage path

type or<?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' => 'local',
            'root' => storage_path('app/uploads'),
            'url' => '/storage/app/uploads',
            'visibility' => 'public',
            'throw' => false,
        ],

        'media' => [
            'driver' => 'local',
            'root' => storage_path('app/media'),
            'url' => '/storage/app/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'),
            'url' => env('AWS_URL'),
            'endpoint' => env('AWS_ENDPOINT'),
            'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
            'throw' => false,
        ],

    ],

];

And here is the rendered file using local storage path and not s3.

Note:

  • S3 dependency is already installed
  • I cleared the cache using cache:clear, config:clear, view:cache

Thanks
Abbas

Hi Abbas,

The uploads and media disks should be set to use the s3 driver, for example:

        'uploads' => [
            'driver' => 's3',

        'media' => [
            'driver' => 's3',

Thanks @daft. I will also need to repeat the s3 configurations in each disk, right?

It was a bit easier in 2.x since I just needed to change the default driver and it works magically.

Yes, that’s correct, except environment variables should be used to keep things DRY. It is more aligned with the way Laravel does things.

There is some replication involved in the PHP configuration but it allows more granular control over where the data is stored. For example, it may be prudent to stores resources locally and media on s3. This was not possible under the previous system.