keyboslice's avatar

Logical place to handle file uploads

Where would be the logical place to handle file uploads in my app? I could use a creator, as I've seen in another video but I need to re-use the logic for updating records too. I'm thinking of having a general service or helper class for my entity, which would be responsible for calling the validation class, and then the tweaks necessary to get the user input into the database - moving file uploads for example, but then this seems to break the single responsibility?

Currently I have my validation class called by my model - which I like because it ensure that any way that I add a row / update a row in the database, validation is called on the data, whereas if a part of my app bypassed my service class and communicated with the model directly, this wouldn't be the case - but as I need to validate the data prior to handling file uploads etc, this would mean that i would be validating the data twice, which seems like a code smell - if anyone could help would be very appreciated as i'm really confused at the moment!

0 likes
1 reply
theUnforgiven's avatar

@keyboslice I either create a repository and interface based on what needs updating/creating i.e Users. So i would have a UserInterface & UserRepository that handles the uploads, creation and edits of a user. Or you could just use it in a controller.

Please or to participate in this conversation.