Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

269
Views
How to solve Firebase Storage: Invalid URL when trying to upload and image react native

I am trying to upload an image to firebase storage, the problem is I get Firebase Storage: Invalid URL when I try to upload it.

First I get the uri from the react-native-image-picker then I use it to make the reference. This is my code:

export async function uploadImage() {
    const options = {
        storageOptions: {
          path: "images",
          mediaType: "photo"
        },
        includeBase64: true
      }
      const result = await launchImageLibrary(options);
      const imagePath = result.assets[0].uri
      console.log(imagePath)
  
      //firebase
      const imageRef = ref(storage, imagePath);
    
      const snapshot = await uploadBytes(imageRef, file, {
        contentType: "image/jpeg",
      });

      console.log("uploaded!")
}

this is the uri printed by the console.log:

file:///data/user/0/com.chatapp/cache/rn_image_picker_lib_temp_f85b1089-267f-4271-9ccb-2f1487d83619.jpg

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

while uploading any to firebase storage

  • you should have permission to upload the file.
  • what do you want to upload the file or any Base64 content
const uploadImage = async () => {
    const options: ImageLibraryOptions = {
      storageOptions: {
        path: 'images',
        mediaType: 'photo',
      },
      includeBase64: true,
    };
    const result = await launchImageLibrary(options);
    if (result) {
      const {assets} = result;
      if (assets && assets.length > 0) {
        try {
          const imagePath = result.assets[0].uri;
          console.log(imagePath);

          //firebase
          const reference = storage().ref('black-t-shirt-sm.png');

          const imageRef = await reference.putFile(imagePath, {
            contentType: 'image/jpeg',
          });
          console.log('imageRef', imageRef);
          // const snapshot = await uploadBytes(imageRef, file, {
          //   contentType: 'image/jpeg',
          // });

          console.log('uploaded!');
        } catch (error) {
          console.log('error', error);
        }
      }
    }
  };

for uploading the file you need to follow its guideline RN Firebase

about 4 years ago · Santiago Trujillo Report

0

storage upload requires platform specific code. I have code snippet at my github playground with storage upload and react-native-image-picker Snippet Essentially

const uri = Platform.OS === 'android' ? uploadUri : uploadUri.replace('file://', '');
const task = storage().ref(ref);
return task.putFile(uri);
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!