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

v6 Storage refFromUrl does not work correctly #2753

Closed
1 of 6 tasks
ThomasFindlay opened this issue Oct 20, 2019 · 17 comments
Closed
1 of 6 tasks

v6 Storage refFromUrl does not work correctly #2753

ThomasFindlay opened this issue Oct 20, 2019 · 17 comments
Assignees
Labels
impact: bug New bug report plugin: storage Firebase Cloud Storage Version: >= 6

Comments

@ThomasFindlay
Copy link

Issue

Describe your issue here

v6 refFromURL does not work on the url below. v5 worked without problems.

firebase.storage().refFromURL(https://firebasestorage.googleapis.com/v0/b/<project-name>.appspot.com/o/<image-path>)

In v6 it throws an error that object was not found even though it exists. I was able to delete the file when using .ref(path).delete(). I don't think that the stack trace is really useful, but here it is.

code:"storage/object-not-found"
jsStack:"Error↵    at Object.delete (blob:file:///06ce93ab-5900-4f65-9a07-f6d7415cdc5e:97535:23)↵    at StorageReference._delete (blob:file:///06ce93ab-5900-4f65-9a07-f6d7415cdc5e:106533:43)↵    at _removeProfilePic$ (blob:file:///06ce93ab-5900-4f65-9a07-f6d7415cdc5e:348611:59)↵    at tryCatch (blob:file:///06ce93ab-5900-4f65-9a07-f6d7415cdc5e:5488:19)↵    at Generator.invoke [as _invoke] (blob:file:///06ce93ab-5900-4f65-9a07-f6d7415cdc5e:5663:24)↵    at Generator.prototype.(anonymous function) [as next] (blob:file:///06ce93ab-5900-4f65-9a07-f6d7415cdc5e:5531:23)↵    at tryCatch (blob:file:///06ce93ab-5900-4f65-9a07-f6d7415cdc5e:5488:19)↵    at invoke (blob:file:///06ce93ab-5900-4f65-9a07-f6d7415cdc5e:5564:22)↵    at blob:file:///06ce93ab-5900-4f65-9a07-f6d7415cdc5e:5594:13↵    at tryCallTwo (blob:file:///06ce93ab-5900-4f65-9a07-f6d7415cdc5e:49272:7)"
message: "[storage/object-not-found] No object exists at the desired reference."
namespace: "storage"
nativeErrorCode: null
nativeErrorMessage: null
stack: "NativeFirebaseError: [storage/object-not-found] No object exists at the desired reference.↵    at StorageReference._delete (blob:file:///06ce93ab-5900-4f65-9a07-f6d7415cdc5e:106533:43)↵    at _removeProfilePic$ (blob:file:///06ce93ab-5900-4f65-9a07-f6d7415cdc5e:348611:59)↵    at tryCatch (blob:file:///06ce93ab-5900-4f65-9a07-f6d7415cdc5e:5488:19)↵    at Generator.invoke [as _invoke] (blob:file:///06ce93ab-5900-4f65-9a07-f6d7415cdc5e:5663:24)↵    at Generator.prototype.(anonymous function) [as next] (blob:file:///06ce93ab-5900-4f65-9a07-f6d7415cdc5e:5531:23)↵    at tryCatch (blob:file:///06ce93ab-5900-4f65-9a07-f6d7415cdc5e:5488:19)↵    at invoke (blob:file:///06ce93ab-5900-4f65-9a07-f6d7415cdc5e:5564:22)↵    at blob:file:///06ce93ab-5900-4f65-9a07-f6d7415cdc5e:5594:13↵    at tryCallTwo (blob:file:///06ce93ab-5900-4f65-9a07-f6d7415cdc5e:49272:7)"


Project Files

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?

  • [ x ] my application is an AndroidX application?
  • [ x ] I am using android/gradle.settings jetifier=true for Android compatibility?
  • [ x ] 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
    • [ x ] Android but have not tested behavior on iOS
    • Both
  • react-native-firebase version you're using that has this issue:
    • 6.0.2
  • Firebase module(s) you're using that has the issue:
    • @react-native-firebase/storage
  • Are you using TypeScript?
    • N


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]

@Ehesp
Copy link
Member

Ehesp commented Oct 21, 2019

Could you try the URL shown in the Firebase console, e.g:

image

The tests also show this working: https://github.com/invertase/react-native-firebase/blob/master/packages/storage/e2e/storage.e2e.js#L39

@stale
Copy link

stale bot commented Nov 18, 2019

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 Nov 18, 2019
@stale
Copy link

stale bot commented Dec 3, 2019

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 Dec 3, 2019
@rkuncewicz
Copy link

rkuncewicz commented Feb 7, 2020

I'm having a similar issue with the https URL. The gs:// URL works as expected, but if we try to use the https:// version the library thinks that it doesn't exist. Also, if there are any spaces in the URL it thinks that the space is the end of the file (i've tried both an encoded space %20 and a regular space ).

I can reproduce this with

  const foo= storage.refFromURL('hhttps://firebasestorage.googleapis.com/v0/b/lumiq-dev.appspot.com/o/file_example_MP3_1MG.mp3?alt=media');
  const bar = await foo.getMetadata();
  console.log(bar);

which results in

Error: [storage/object-not-found] No object exists at desired reference.

Using gs://lumiq-dev.appspot.com/file_example_MP3_1MG.mp3 works.

If you use https://firebasestorage.googleapis.com/v0/b/lumiq-dev.appspot.com/o/file%20example%20MP3%201MG.mp3?alt=media it will parse the path as just file.

Is this expected? v5 was working properly.

@Rob117
Copy link
Contributor

Rob117 commented Mar 18, 2020

This is 100% still an issue, btw. I'm experiencing it exactly as described above.

I have no idea if it helps, but this is only happening on android.

@sarykemmoun
Copy link

sarykemmoun commented Mar 23, 2020

I have this issue too.
The download url is correct, I use it for displaying the image properly, But when I do refFromUrl and try to delete the ref I'm getting storage/object-not-found

Worked well on V5.

@Ehesp Ehesp added impact: bug New bug report plugin: storage Firebase Cloud Storage and removed Type: Stale Issue has become stale - automatically added by Stale bot labels Mar 23, 2020
@Ehesp Ehesp reopened this Mar 23, 2020
@russellwheatley russellwheatley removed their assignment Mar 26, 2020
@dackers86
Copy link
Member

@rkuncewicz We seem to have an issue with handling encoded urls which I will create a new issue for.

@ThomasFindlay If you can still provide an example of what url you are using then we can potentially se that for an different test case?

@sarykemmoun If you could also provide an example of this, most cases we have found so far have been encoded or incorrect urls

@dackers86
Copy link
Member

dackers86 commented Mar 30, 2020

PR Added at #3369

@HwangPeter
Copy link

HwangPeter commented Apr 21, 2020

Seems to have something with how the ref is generated from HTTP URLs. I printed the storage ref that "doesn't exist" to console, it was missing the ".appspot.com" part of the bucket name. Normally you get something like gs://${project id}.appspot.com/${restOfPath}

As a temporary workaround I grabbed the rest of the pathname and created a new ref using storage().ref().child(${restOfPath});

@stale
Copy link

stale bot commented May 19, 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 19, 2020
@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. Like @HwangPeter observed, I confirmed that valid refs have a bucket named "{BUCKET}.appspot.com" but the refs from refFromURL have a bucket named "{BUCKET}".

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

PR added at #3775

@hackrx
Copy link

hackrx commented Jun 21, 2020

I am also facing the same issue, refFromURL is not working
I generated using below code,

 try {
            //console.log('Photo we need to delete ', this.state.photoURL);
            const deletePostImageFromStorageRef = Storage().refFromURL(
              this.state.photoURL,
            );
}
catch(err){
console.log("Error ",err);
}

And the error I got is
Error in deleting the post NativeFirebaseError: [storage/object-not-found] No object exists at the desired reference. at StorageReference._delete
Package.json file

 "@react-native-firebase/app": "^7.0.1",
    "@react-native-firebase/auth": "^7.0.2",
    "@react-native-firebase/firestore": "^7.1.2",
    "@react-native-firebase/functions": "^7.1.3",
    "@react-native-firebase/storage": "^7.1.2",

Any workaround for this?

@hackrx
Copy link

hackrx commented Jun 23, 2020

Solved this issue #3820

@enosh94
Copy link

enosh94 commented Jun 25, 2020

I am having the exact same issue when using refFromURL. And following temporary solution worked like a charm.

const fileRefFromUrl = storage().refFromURL("https://<pathtoyourfile> ");
storage().ref(fileRefFromUrl .fullPath).delete()

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

@mikehardy
Copy link
Collaborator

@enosh94 there's a PR #3775 working through review now, you can probably apply the fix locally via https://github.com/ds300/patch-package - when you say it "needs to be fixed" it implies someone should do it, with open source that's all of us and if you are suffering from this exact problem you would be a perfect test case, getting success reports for the proposed change would help it be fixed

@akinlekan28
Copy link

I am having the exact same issue when using refFromURL. And following temporary solution worked like a charm.

const fileRefFromUrl = storage().refFromURL("https://<pathtoyourfile> ");
storage().ref(fileRefFromUrl .fullPath).delete()

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

Thank you very much for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impact: bug New bug report plugin: storage Firebase Cloud Storage Version: >= 6
Projects
None yet
Development

No branches or pull requests