Retool image upload

Hello, I am trying save images uploaded in retool in my database by POST API base64 of the image. I'm using file uploader and I can get base64 (from fileInput.value[]), but base64 string is too large and I get payload is too big error when I try to pass base64 with POST API. Is there a way to compress bade64?

1 Like

Hello, here is a good question about base64 compression for your reference.

How to compress base64 string [closed]

Base64 is already encoded in a way which does not suit most compression algorithms

@AnsonHwang I didn't find answer in that post, most comments said it's not possible to compress base64. What could be an alternative? How can I pass selected image with POST API?(without getting large payload error)

How about save image to Retool fileStorage or something alike, such as amazon s3, and keep the file id in your database field?

It's not recommend to save such a big file data to database.

1 Like

@AnsonHwang I'll be saving image to google storage bucket(to get url), so I need to pass base64 (or buffer), but base64 is too large. I tried to use compressjs(by adding library) to compress the image( fileinput.files[0]), but I get Compress is not defined when I run query.

1 Like