简体   繁体   中英

Why and how to convert file into a base64 string

I am using React Native to send a post request to an endpoint. In this post request, one of the params has to be a file. Can I set the param to the direct image selected from the camera roll, or turn it into a string first, using a base64 string?

You can covert any image into base64 using package called imageStore which comes from react-native

ImageStore.getBase64ForTag(uri,success=>{
//do something with your image's base64
},failure=>{
//handle error
})

pass uri which you get from cameraRoll

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM