React-native-firebase: [RN 0.62.2] [Android] The storage Uri cannot contain a path element.

Created on 18 Jun 2020  路  8Comments  路  Source: invertase/react-native-firebase

Error: Exception in HostObject::get(propName:RNFBStorageModule): java.lang.IllegalArgumentException: The storage Uri cannot contain a path element.

p.s. File picker uri output: Picked succesfully content://media/external/images/media/33

Platform.OS === 'ios' ? uri.replace('file://', '') : uri;
"@react-native-firebase/storage": "^7.1.4",

Thanks

Storage Waiting for User Response

Most helpful comment

You haven't made this coherent to follow. Provide a complete code snippet or a more cohesive explanation.

Looking at the error, however, it seems to be coming from an incorrect parameter being given to a function

@andersonaddo i get the same issue on Android

const getFileLocalPath = response => {
  const { path, uri } = response;
  return Platform.OS === 'android' ? path : uri;
};

const createStorageReferenceToFile = response => {
  const { fileName } = response;
  const id = generateRandomString();
  return FireBaseStorage.ref(`images/${id}-${fileName}`);
};

export const uploadFileToFireBase = response => {
  const fileSource = getFileLocalPath(response);
  const storageRef = createStorageReferenceToFile(response);
  return storageRef.putFile(fileSource);
};

 const uploadTask = uploadFileToFireBase(response);

    uploadTask.on(
      storage.TaskEvent.STATE_CHANGED,
      async snapshot => {
        setProgress(
          getPercentage(snapshot.bytesTransferred / snapshot.totalBytes)
        );
        if (snapshot.state === storage.TaskState.SUCCESS) {
          setDownloadURL(await snapshot.ref.getDownloadURL());
          setSuccess(true);
          setUploading(false);
        }
      },
      error => {
        setError(error);
      }
    );

All 8 comments

You haven't made this coherent to follow. Provide a complete code snippet or a more cohesive explanation.

Looking at the error, however, it seems to be coming from an incorrect parameter being given to a function

You haven't made this coherent to follow. Provide a complete code snippet or a more cohesive explanation.

Looking at the error, however, it seems to be coming from an incorrect parameter being given to a function

@andersonaddo i get the same issue on Android

const getFileLocalPath = response => {
  const { path, uri } = response;
  return Platform.OS === 'android' ? path : uri;
};

const createStorageReferenceToFile = response => {
  const { fileName } = response;
  const id = generateRandomString();
  return FireBaseStorage.ref(`images/${id}-${fileName}`);
};

export const uploadFileToFireBase = response => {
  const fileSource = getFileLocalPath(response);
  const storageRef = createStorageReferenceToFile(response);
  return storageRef.putFile(fileSource);
};

 const uploadTask = uploadFileToFireBase(response);

    uploadTask.on(
      storage.TaskEvent.STATE_CHANGED,
      async snapshot => {
        setProgress(
          getPercentage(snapshot.bytesTransferred / snapshot.totalBytes)
        );
        if (snapshot.state === storage.TaskState.SUCCESS) {
          setDownloadURL(await snapshot.ref.getDownloadURL());
          setSuccess(true);
          setUploading(false);
        }
      },
      error => {
        setError(error);
      }
    );

If you want somebody to help you, please fill in the template.

If you want somebody to help you, please fill in the template.

Dear guy, you cannot close the issue and then refer it as a duplicated ticket in future, let me know the template, i thought above code snipset described the bug of the library

@kelvin-dev was not closed duplicate. Was closed as no template.
When you open an issue here there is an issue template, it covers what we need to know to start helping you.
By filling it in, you are helping us help you.
By not filling it in you are saying "I won't give you the information you need to help, so you can just close this"

@kelvin-dev just ignore them, they suck

@phathuynh5519 abusive to people trying to help, and explaining how best to get it, a winning strategy!

@kelvin-dev just ignore them, they suck

Are you from GMT+7, let me know if u are open to new opportunity, i LIKE your code snipset

Was this page helpful?
0 / 5 - 0 ratings