Base64 encode images

Hello,

Is there a way i can base64 encode an image(cameraRoll and/or web image) without the need to use ExpoKit and detach the project?

I searched for base64 encode libraries but they all require extra native code.

Thank you in advance for your help.
Cheers.
Tudor

1 Like

Hi! This is something we plan to support soon but don’t have yet. In the current version, on iOS, if you add the option noData: false in ImagePicker calls you will get a base64 result in the result object. This is only on iOS for now though, and the new API will be different.

If this is for uploading images to a server, you can also do it without base64 encoding as seen here: https://github.com/exponent/image-upload-example

In fact not using base64 encoding is preferred since then you are not reading a bunch of bytes on JavaScript. When you directly add the file to fetch, all the bytes stay on the native side.

Hi all!

is there no way to get base64 or binary data from image in expo?
Is the base64 “hack” working on android too?

Has anyone created a file upload to an signed S3 upload url?
This needs to post directly the binary data of the image.

Or upload an image to api gateway with lambda function?

UPDATE: I have now used a s3 createPresignedPost to
generate a complete formData object incl. the expo image
and upload it then direct to s3.

Thanks,
Ben

Hi bkodd. Any code showing how you did this. I have been trying unsuccesfuly for a while now.