1

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',
    ],
];
Reza Mousavi
  • 4,420
  • 5
  • 31
  • 48
ev.werkz
  • 61
  • 8

1 Answers1

1

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.

Hardik Satasiya
  • 9,547
  • 3
  • 22
  • 40
  • You're right. Thank you. That means a solution would be to create an S3 file upload class or function yourself. I wonder if you can create something similar like "System \ Models \ File" and use it globally. I think it is impractical not to use the table, and for each picture nen own field in each table to create and extra functions to write for it. – ev.werkz Oct 04 '18 at 08:26
  • yes, you can create your own table and extend `System\Models\File` in new table you need to store `path` of `s3` items instead local one and you are good to go – Hardik Satasiya Oct 04 '18 at 12:24