Reputation: 158
In my React Native app I need to convert some base64 images back to uri. Reason being that uris are temporary and can be deleted from the cache. There are a lot of ways of converting URIs to base64 but not vice versa. Does anyone know how to do this?
Upvotes: 0
Views: 3266
Reputation: 56
You could use the buffer library to decode base64 encoded data in a react native app.
npm i buffer
Once installed you can import the buffer library into your react native app
import { Buffer } from 'buffer';
and then decode base64 encoded data
Buffer.from(data, 'base64');
The line above returns the decoded data as bytes and
Buffer.from(data, 'base64').toString('ascii');
returns the decoded data as an ascii encoded string.
Upvotes: 3