when holding a download url of an image in firebase storage and trying to get it's reference in firebase using: firebase.storage().refFromURL(downloadUrl)
i get the following error:
Error: [storage/object-not-found] No object exists at the desired reference.
NativeFirebaseError: [storage/object-not-found] No object exists at the desired reference.
Click To Expand
#### `package.json`:
"@react-native-firebase/analytics": "^6.3.0",
"@react-native-firebase/app": "^6.3.0",
"@react-native-firebase/auth": "^6.3.0",
"@react-native-firebase/crashlytics": "^6.3.0",
"@react-native-firebase/firestore": "^6.3.0",
"@react-native-firebase/functions": "^6.3.0",
"@react-native-firebase/storage": "^6.3.0",
#### `firebase.json` for react-native-firebase v6:
{
"functions": {
"predeploy": ["yarn --cwd \"$RESOURCE_DIR\" lint", "yarn --cwd \"$RESOURCE_DIR\" build"],
"source": "functions"
},
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"storage": {
"rules": "storage.rules"
}
}
### iOS
#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like:
# N/A
#### `AppDelegate.m`:
// N/A
Click To Expand
#### Have you converted to AndroidX? - [ ] my application is an AndroidX application? - [ ] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [ ] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`:
// N/A
#### `android/app/build.gradle`:
// N/A
#### `android/settings.gradle`:
// N/A
#### `MainApplication.java`:
// N/A
#### `AndroidManifest.xml`:
<!-- N/A -->
Click To Expand
**`react-native info` output:**
OUTPUT GOES HERE
- **Platform that you're experiencing the issue on**:
- [ ] iOS
- [ ] Android
- [ ] **iOS** but have not tested behavior on Android
- [ ] **Android** but have not tested behavior on iOS
- [ ] Both
- **`react-native-firebase` version you're using that has this issue:**
- `e.g. 5.4.3`
- **`Firebase` module(s) you're using that has the issue:**
- `e.g. Instance ID`
- **Are you using `TypeScript`?**
- `Y/N` & `VERSION`
Think react-native-firebase is great? Please consider supporting all of the project maintainers and contributors by donating via our Open Collective where all contributors can submit expenses. [Learn More]
React Native Firebase and Invertase on Twitter for updates on the library.Well it seems to be from the error that the URL you're passing in doesn't correlate with anything in your storage bucket.
Are you sure you're passing in the right URL? Maybe console.log downloadUrl right before you pass it in. Also maybe consider putting it in a browser and seeing if you get the resource in the first place.
Btw, you should include a proper code snippet to make troubleshooting easier.
i am sure the url is ok.
if i use it in
also putting the url in the browser works.
@naomipindrus can you give an example URL that you're using?
@Salakar something like this https://firebasestorage.googleapis.com/v0/........
i am not sure i can give the whole url
It is not parsing a download URL correctly.
The path is:
chat/icons/74bd15d3-8620-48a4-aedf-e7ce30731db4
The download URL:
https://{MY FIREBASE_PROJECT}/o/chat%2Ficons%2F74bd15d3-8620-48a4-aedf-e7ce30731db4?alt=media&token=30eaa53e-669a-42ef-b0c0-80a2bbc6d6dd
And here is what refFromURL() spits out:
{
...
fullPath: 'chat',
name: 'chat',
path: 'chat'
...
}
It is just finding the first segment of the path.
This is 100% an issue on Android that I am also experiencing right now. If you need an example URL,
https://firebasestorage.googleapis.com/v0/b/${PROJECT NAME}/o/W76K1NJvjxM4WkAKLebsp4r9Sko2%2F829f70e9f4b37b9879a947532a08af73e98bb5b180c03bb969fe677958311696.jpeg?alt=media&token=2c905390-4bc6-4f7f-8aae-cc0b92e03aa5
It works on iOS, but not on Android.
I think it has to do with path parsing as mentioned here.
So, my problem was that I was getting the downloadURL from ref.getDownloadURL() and then using a separate library to download the file and write it locally.
Instead, if I just use the SDK's internal writeToFile, it works without issue.
Hello 馃憢, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.
Still an issue.
Hello 馃憢, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.
Not fixed.
Can you try the latest release, I thought this was fixed by #3369
This issue still exists with version 7.0.1. The slashes within the path are now handled correctly, but the ref is still not valid. Valid refs have a bucket named "{BUCKET}.appspot.com" but the refs from refFromURL have a bucket named "{BUCKET}". See #2753.
I solved that :
const ref = storage().refFromURL("https:// .... ");
storage().ref(ref.fullPath).delete()
@DnzDmR your solution works like a charm. Thanks!
However, this is a workaround. This bug needs to be fixed.
Hello 馃憢, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.
Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.
Most helpful comment
I solved that :
const ref = storage().refFromURL("https:// .... ");
storage().ref(ref.fullPath).delete()