VertexBuffer's avatar

Best way to handle image uploads on a REST api?

So I've already got the actual image upload part done, but my question is more-so how to handle this when it comes to the frontend.

When it comes to getting or editing a resource, should I be returning just the name of the file and then doing a lookup from the frontend? Or should I return the actual file itself inside the response along with other information?

I'm not really sure the best/cleanest way to handle this.

0 likes
1 reply
fylzero's avatar

@zyxxyzyxz I would suggest uploading to s3 and storing the relative path. When you display the image just reference the s3 url. If you need to modify or reupload just replace the image on S3. Use the relative path so you can make you image storage service more flexible. You can store the S3 url in your environments variables.

Hope this helps.

24 likes

Please or to participate in this conversation.