Burano's avatar

Best way to handle image uploads?

So I was hoping to make this a bit more of a discussion as well as some advice. Everytime I make a new project, I write everything nice and clean but as soon as it comes to image/file uploading, everything becomes a mess.

For example usually when I'm building a CRUD application, I just define an Edit template and use it as the create template as well, since I can just check in the template if any data was passed to it from the controller.

However the issue is when it comes to images/files this becomes kind of a pain. The main issue I run into is that when using a file uploader, even a basic native browser one, you're generally going to be dealing with File/Blob, but how exactly do you manage that between the server and client?

For example, I might use something like S3 storage that saves a URL to the database after I submit a form along with the file, but now when doing my Edit view technique, I'm in a bit of a pickle because I've got a URL and not a File/Blob. Obviously I can add some code to make a request and then use the response as the File/Blob, but this adds a lot of complexity to the view and generally I find it becomes very unmanageable especially when you are dealing with multiple files.

I was wondering if anyone could provide any advice on how they deal with file uploads and what they consider to be the "cleanest" method in their opinion?

0 likes
1 reply

Please or to participate in this conversation.