We have frontend as Google PWA application and REST API on backend. We need to send some really big images selected by our PWA users to backend (dozens megabyte size). Currently, PWA user selects an image from cell phone file system (as a result he can see it on the cell phone screen in PWA UI) and then press "Upload" button to send it to backend via REST API.
Initially to implement this functionality really quick we sent image data in base64 format through network and store it in the same format in DB field as a string.
Now we decided to get rid from base64 encoding file sending and on the backend I've implemented multipart/form-data
receiving in binary format as was advised on this site many times and store it in DB field with bytea
type. Excellent!
However, for some reason our frontend dev told me he can't simple get binary image data as PWA UI translate it to base64 itself after loading from file system. And UI DOM model keep image in <img>
element just in this format. So to sending data from UI to backend he needs to do base64 decoding beforehand.
My question is how to either show images in binary format in UI without base64 encoding or how to avoid keeping both base64 and binary data at frontend at the same time (remember our images have size of dozens megabytes)?