I'm building a real time chat application like Whatsapp. I have a websocket server with node+express, but I'm a bit confused on which flow I should use.

I'm considering sending the image as binary data through the websocket to the server, process it and store it in AWS s3, and then send the URL back to the user.

Another idea I have thought about is making have an endpoint to make a PUT request to the server, store that Image in S3, and then checking for the specific chatroom id in MongoDB, and then send the Url through websocket.

Can someone aware me on a better solution than what I currently have?

  • 4
    What problems do you foresee with either approach?
    – user253751
    Jan 18, 2021 at 13:07
  • Just a note that the way you describe the PUT approach doesn't follow the proper PUT semantics. PUT should be executed against the URI that will be used to GET. You should use POST here, if I understand correctly.
    – JimmyJames
    Sep 20, 2021 at 20:32

1 Answer 1


I recommend you look into Uppy. It will simplify an implementation of your option 2 and provide some nice extra utility out of the box.

I wrote a similar piece of functionality some months ago. Uppy (together with its server-side module called "Uppy Companion") handles the image upload and the save to S3. Once that's done, the client gets the URL of the uploaded image back and can do whatever it wants with it (e.g. send it via websocket to another user in the chatroom).

Not the answer you're looking for? Browse other questions tagged or ask your own question.