Search code examples
amazon-s3octobercmsoctobercms-plugins

Why october cms don't save attachments on db by upload images with amazon-s3?


I have a problem with AWS s3 and October cms. If I upload images or files from media page s3 works fine, but if I upload images from Object (System or Widget) is attachment_id, and attachment_type on the system_file table is empty. So, I cant fetch all images by model.

Someone have any idea whether it is an October cms error or I still have something to configure?

filesystem.php config:

'default' => 's3',
'cloud' => 's3',
'disks' => [
    'local' => [
        'driver' => 'local',
        'root'   => storage_path('app'),
    ],
    's3' => [
        'driver' => 's3',
        'key'    => env('AWS3_KEY'),
        'secret' => env('AWS3_SECRET'),
        'region' => env('AWS3_REGION'),
        'bucket' => env('AWS3_BUCKET'),
    ],

cms.php config:

'storage' => [
    'uploads' => [
        'disk'   => 's3',
        'folder' => 'chemie/uploaded-files',
        'path'   => 'https://amazon/s3/bucket-name/chemie',
    ],
    'media' => [
        'disk'   => 's3',
        'folder' => 'chemie',
        'path'   => 'https://amazon/s3/bucket-name/chemie',
    ],
],

sistem_file db table: image

Model example:

/**
 * @var array
 */
public $attachMany = [
    'gallery_images' => [
        'System\Models\File',
    ],
];

Solution

  • Actually its not possible as widget/file uploader etc make relation to files and save that relation in database.

    where as in media that is just plain path either of local-disk or remote-disk based on configuration

    So, if you want to add images which are stored on s3 you can add repeater field which have media widget in it to select files and upload files in this way you can select or add multiple files.

    as from code I see there is no possible implementation for remote-disk in database FileSystem

    Media uses remote disk

    enter image description here

    File-upload widget/Model uses only local disk

    enter image description here

    if you have any doubts please comment.