Custom Upload directory using mediafinder

Hi,

I’m using Tailor’s mediafinder to upload PDFs, and I want to change the default upload path for this specific module/blueprint and want the rest of them to use default as it was before, config is set to storage/app/media in filesystems.php. I’ve modified the configuration as follows:

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

'tenders' => [ // Custom configuration for the new path
    'driver' => 'local',
    'root' => dirname(dirname(__DIR__)) . '/storage/app/media',// Path for tenders that i want to upload one directory above my October CMS directory. 
    'url' => 'http://127.0.0.1:8000/storage/app/media',
    'visibility' => 'public',
    'throw' => false,
],

Basically it was working before, when i altered

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

I’m new to this and I’d appreciate for pointing out wherever I’m going wrong i tried the documentation too couldn’t find what i wanted. Thank you…

At the moment, the mediafinder only supports storing files in one driver. We have plans to improve this in the future.

We could introduce an event that allows setting a custom driver inside file modules/media/classes/MediaLibrary.php and getStorageDisk method, however, it’s not clear how this could be used to swap the disk based on the Tailor blueprint.

probably good idea is, that use a some kind of option in yaml config, like destination, or uploadDirectory or something

gallery:
   type: mediafinder
   label: Gallery
   mode: image
   storage: media // default value, optional based on defined filesystem?
   directory: downloads

for example, this configuration will use media filesystem, then default storage will be storage/app/media and directive for directory will upload file to storage/app/media/downloads

from setting from OP

// settings inside filesystem.php
'tenders' => [ // Custom configuration for the new path
    'driver' => 'local',
    'root' => dirname(dirname(__DIR__)) . '/tenders',
    'url' => 'http://127.0.0.1:8000/tenders',
    'visibility' => 'public',
    'throw' => false,
],

and config in taylor will be:

tenders:
   type: mediafinder
   label: Gallery
   mode: image
   storage: tenders

what u think about this solution @daft ?

1 Like

I like it for the directory. Except the driver won’t be stored on the model, so perhaps it should go in the site definition?

why not on model? i know, that currently “mediafinder” is without any database storage informations about files, but… probably, some kind of relation between filesystem and medialibrary will be helpfull in future, for storing metadata like source, exif, title, description, etc. not it is only filebrowser, right?

On further thoughts, we could store the disk name as part of the string, e.g. disk@path/to/file.jpg

I have added these notes to our internal tracker, thanks for your advice, @snipi!

1 Like

this will be helpfull for other use cases, like, when you wish to list different folders like s3, dropbox, etc. but, currently there are no “connectors” in mediafilder as well. but… still a perfect way how to prepare such a usefull funcionality