2 years ago

Spatie MediaLibrary default storage depending on the model

Posted 2 years ago by bufferoverflow


So this package default storage path is: /public/{id}/image.jpg

But what happens if i use two models (posts and products) and i want to store them like this:

// Posts

// Products

First i thought that i could use two disks pointing at those folders, but i think that creating disk for each model is not the correct solution.

Later i found the "custom folder struture" at the package docs https://docs.spatie.be/laravel-medialibrary/v7/advanced-usage/using-a-custom-directory-structure, but i thought it was too complex for only adding a folder in the file path.

Do you know a simpler way to divide media in model folders?

Please sign in or create an account to participate in this conversation.