The main thing i want to get when a user selects a photo from their album is to get a url from that photo that i can use in my users db. Putting the url to user document in firebase is working and the ImagePicker is working. My main question is how would i(through firebase storage) get a actual url and not something like this:
250F8B0C-72D3-43D4-9CDA-B7F6D8A11F81.jpg
code:
const [image, setImage] = useState("");
//functions
const pickImage = async () => {
try {
// No permissions request is necessary for launching the image library
let result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.All,
allowsEditing: true,
aspect: [4, 3],
quality: 1,
});
console.log(result);
if (!result.canceled) {
auth.currentUser.photoURL = result.uri
setImage(result.uri);
console.log(result.uri)
imgFirebase()
}
{/**
await updateDoc(doc(db, "users", uid, {
photoURL: result.uri.toString()
}))
*/}
}
catch(E) {
alert(E)
}
};
async function imgFirebase () {
const d = await fetch(image)
const dd = await d.blob()
const fileName = image.substring(image.lastIndexOf("/")+1)
console.log(fileName)
const storage = getStorage();
const storageRef = ref(storage, fileName);
uploadBytes(storageRef,dd).then((snapshot) => {
console.log('Uploaded a blob or file!');
});
const httpsReference = ref(storage, 'https://firebasestorage.googleapis.com/b/bucket/o/images%20stars.jpg');
}
storage structure what the firebase storage looks like: **note that if i press on the image it actually gives me the url in a new tab...i have tried the getDownloadUrl function from the docs but its also giving me errors with the storage reference
in my imgFirebase function what what i need to get to get just the url of the img/blob that i get from the Image picker/firebase storage