0

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?

Anayo Oleru
  • 468
  • 5
  • 8
  • 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 Answers1

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