Building with React native I have used Firebase storage to upload files and return a download url to store in the database and save space but, If I want to allow a user to share images/videos to instagram via expo-share or react-native-share, It seems I need to have a local file URL. Is there a way to download the file from storage and save locally then pass? Has anyone else figured out how to share from the cloud?
was attempting:
//imageUrl = getDownloadURL() stored from firebase storage
const shareToInstagram = async (image: {type: string, url: string}) => {
const storage = fbApp.storage()
const fileRef = storage.refFromURL(image.url)
fileRef.child(image.url).getDownloadURL()
.then((url) => {
const imagePath = `${Platform.OS==="android"?"/storage/emulated/0/Download":fs.TemporaryDirectoryPath}/${((Math.random() * 1000) | 0)}.jpeg`;
fs.downloadFile({
fromUrl: url,
toFile: imagePath
}).promise
.then((result: any) => {
console.log(imagePath, result); //here you get temporary path
Sharing.shareAsync(imagePath);
})
.catch((e: any) => {
console.log(e,"error");
})
})
};
FirebaseError: Firebase Storage: Object 'tricks/8eb4ff46-4b96-44cb-b52c-390550d96b49/https:/firebasestorage.googleapis.com/v0/b/aerial-blackbook.appspot.com/o/tricks%2F8eb4ff46-4b96-44cb-b52c-390550d96b49?alt=media&token=0a3cc5cc-ff99-4788-9b9e-017450cfe809' does not exist. (storage/object-not-found)
for anyone else struggling to understand this : This is what worked to share from firestore to instagram via react native with expo: