Here is the function that uses expo-camera to take a picture, and this works correctly
//Local Image State object, for file URL, Firebase URL
const [image, setImage] = useState([]);
const [fireURI, setURI] = useState([]);
const takePicture = async () => {
// null parameter, options are set on Camera component not in takePicAsync()
const data = await camera.takePictureAsync(null);
const source = await data.uri;
setImage([...image, source]);
//Renders photo after
setUploading(true);
//Closes camera
setIsCameraOpen(false);
setZoom(0);
};
And here is the function that send the images to Firebase storage and gets the download URL for each, this was working before and now all of a sudden I get error "RangeError Failed to construct 'Response': The status provided (0) is outside the range [200, 599]"
const handleFirebaseURI = async () => {
const ImageURL = [];
image.map(async (images) => {
var metadata = {
contentType: "image/jpeg",
};
// ERROR HERE ON FETCH, if I remove the firebase logic the error still occurs
const response = await fetch(images);
const blob = await response.blob();
const filename = await images.substring(images.lastIndexOf("/") + 1);
//Reference to Firebase storage, folder created for each user email
const imageRef = ref(storage, `${ID}/${filename}`);
try {
//Uploads Image to Firebase Storage
const uploadTask = await uploadBytes(imageRef, blob, metadata);
// Get the download URL and wait for its resolution
const url = await getDownloadURL(uploadTask.ref);
ImageURL.push(url);
setImages({ ImageURL });
setUploadingToFirebase(true);
} catch (error) {
alert(error);
}
});
What is causing the error when fetching local files? All of this code was working fine recently what could have changed?