maybe I just can’t think out of the box right now, but I have a problem with my react native app that I couldn’t solve.
I want to upload Pictures from my App to a supabase Storage Bucket. The Docs mention, that I need to convert the image to base64 to upload direct from react native.
I tried to convert my file with expo FileSystem to a base64 String, but the image is not viewable. Not in my app, not in the browser and not if I download the file.
Where is the problem in my code? Can anyone help me?
const album = await MediaLibrary.getAssetsAsync({album: albumId})
const resUpload = album.assets.map(async (asset) => {
const name = uuid.v4()
const folder =....
return await supabase.storage.from("sbucket").upload(folder + "/" + name, decode("data:image/png;base64," + await FileSystem.readAsStringAsync(asset.uri)), {
contentType: 'image/png'
})
})
I tried to upload the image to supabase bucket and it completes. But I am not able to open or view my image. Something with the base64 encoding is wrong.
Max Handke is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.