Base64 to Image File

SDK version: 35.0.0
Platform: Android, Android emulator

I need to convert a base64 string into an image file using FileSystem.writeAsStringAsync but it is not creating the image correctly. Instead it is saving the file in text format.

const uri = FileSystem.cacheDirectory + 'image.png';
const base64Image = "data:image/png;base64,iVBORw0KGgoAAAANSUhE...";
const Base64Code = base64Image.split("data:image/png;base64,")[1];
await FileSystem.writeAsStringAsync(uri, Base64Code), { encoding: FileSystem.EncodingType.Base64 };

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.