Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refFromUrl using https://...... is not working #3260

Closed
1 of 10 tasks
naomipindrus opened this issue Mar 1, 2020 · 18 comments
Closed
1 of 10 tasks

refFromUrl using https://...... is not working #3260

naomipindrus opened this issue Mar 1, 2020 · 18 comments
Labels
plugin: storage Firebase Cloud Storage Type: Stale Issue has become stale - automatically added by Stale bot

Comments

@naomipindrus
Copy link

naomipindrus commented Mar 1, 2020

Issue

Describe your issue here

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.

Project Files

Javascript

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

Click To Expand

ios/Podfile:

  • I'm not using Pods
  • I'm using Pods and my Podfile looks like:
# N/A

AppDelegate.m:

// N/A


Android

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 -->


Environment

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]

@andersonaddo
Copy link
Contributor

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.

@naomipindrus
Copy link
Author

i am sure the url is ok.
if i use it in it displays currectly.
also putting the url in the browser works.

@Salakar
Copy link
Member

Salakar commented Mar 4, 2020

@naomipindrus can you give an example URL that you're using?

@Salakar Salakar added Workflow: Waiting for User Response Blocked waiting for user response. plugin: storage Firebase Cloud Storage labels Mar 4, 2020
@naomipindrus
Copy link
Author

naomipindrus commented Mar 5, 2020

@Salakar something like this https://firebasestorage.googleapis.com/v0/........
i am not sure i can give the whole url

@phatmann
Copy link

phatmann commented Mar 9, 2020

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.

@russellwheatley russellwheatley added Version: >= 6 and removed Workflow: Waiting for User Response Blocked waiting for user response. labels Mar 12, 2020
@Rob117
Copy link
Contributor

Rob117 commented Mar 18, 2020

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.

@Rob117
Copy link
Contributor

Rob117 commented Mar 18, 2020

Solved

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.

@stale
Copy link

stale bot commented Apr 15, 2020

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.

@stale stale bot added the Type: Stale Issue has become stale - automatically added by Stale bot label Apr 15, 2020
@phatmann
Copy link

Still an issue.

@stale stale bot removed the Type: Stale Issue has become stale - automatically added by Stale bot label Apr 15, 2020
@stale
Copy link

stale bot commented May 13, 2020

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.

@stale stale bot added the Type: Stale Issue has become stale - automatically added by Stale bot label May 13, 2020
@phatmann
Copy link

Not fixed.

@stale stale bot removed the Type: Stale Issue has become stale - automatically added by Stale bot label May 13, 2020
@Salakar
Copy link
Member

Salakar commented May 14, 2020

Can you try the latest release, I thought this was fixed by #3369

@phatmann
Copy link

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.

@DnzDmR
Copy link

DnzDmR commented May 24, 2020

I solved that :
const ref = storage().refFromURL("https:// .... ");
storage().ref(ref.fullPath).delete()

@phatmann
Copy link

@DnzDmR your solution works like a charm. Thanks!

However, this is a workaround. This bug needs to be fixed.

@stale
Copy link

stale bot commented Jun 28, 2020

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.

@stale stale bot added the Type: Stale Issue has become stale - automatically added by Stale bot label Jun 28, 2020
@stale
Copy link

stale bot commented Jul 13, 2020

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.

@stale stale bot closed this as completed Jul 13, 2020
@Nantris
Copy link

Nantris commented Jan 31, 2024

I haven't tried the workaround yet, but I seem to be experiencing the same error, No object exists at the desired reference, (only happens on iOS.)

But I don't think we're using https:// at any point so I'm still more confused by this error. Is it possible that using this patch to make React Native work in a monorepo is the cause of the error? It seems unlikely since everything else works fine: nrwl/nx#20115 (comment)

Edit: Turned out to be unrelated to React Native Firebase; just some mystery bug that appeared from seemingly nowhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: storage Firebase Cloud Storage Type: Stale Issue has become stale - automatically added by Stale bot
Projects
None yet
Development

No branches or pull requests

8 participants