I want to convert a base64 URL to an image file in react-native. Is there a package or an easy way to implement this?
Asked
Active
Viewed 641 times
0
-
probably duplicated with https://stackoverflow.com/questions/48837840/in-react-native-how-to-convert-a-base64-image-to-jpg-then-save-to-temp-path – cuongtd Jan 07 '21 at 06:45
1 Answers
0
You can try using react-native-fs
like so:
import RNFS from 'react-native-fs';
const imageDate = '<some base64 data>';
const imagePath = `${RNFS.TemporaryDirectoryPath}image.jpg`;
RNFS.writeFile(imagePath, imageData, 'base64')
.then(() => console.log('Image converted to jpg and saved at ' + imagePath));

Nooruddin Lakhani
- 7,507
- 2
- 19
- 39
-
thanks for the suggestion. But what it converted to, is no different from the base64 pathName – Anayo Oleru Jan 07 '21 at 08:02