Skip to content

Unable to upload to multiple buckets #775

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

Closed
facuacostag opened this issue Jan 23, 2018 · 15 comments
Closed

Unable to upload to multiple buckets #775

facuacostag opened this issue Jan 23, 2018 · 15 comments
Assignees
Labels
help: general General help wanted help: needs-triage Issue needs additional investigation/triaging. plugin: storage Firebase Cloud Storage

Comments

@facuacostag
Copy link
Contributor

Hi, we are using multiple buckets on our app. Since there is no documentation for the Storage on the Docs we are using the official one provided by Google. They say in there that for using a different bucket and not the default one, we need to use this function:

var storage = firebase.app().storage("gs://my-custom-bucket");

While doing this, I get a red screen saying that Invalid FirebaseApp instance passed to firebase.storage(app <--). Looking at the source code, It seems that this option is not available right now on RNFirebase and It's a needed one.

I tried to use other app instance changing the bucket and sending it into the storage() function, but since the user is logged into the other app instance, we are not able to upload files to that bucket.

Is there a workaround for doing this?

@Ehesp
Copy link
Member

Ehesp commented Jan 23, 2018

Hello, currently the string version of the URL doesn't work in RNFirebase. You can however pass the App instance you want.

@k0ff33
Copy link

k0ff33 commented Jan 23, 2018

What is the best way to extend the current App instance with the new storage url without recreating the object?

Creating a completely new App instance resulted in having a user logged in to one (with default bucket) and not to the other one.

@Salakar
Copy link
Contributor

Salakar commented Jan 23, 2018

@k0ff33 #675 might be a good reference for you if you're looking at contributing as per chat on discord - this is how the multi-db by url support was implemented for database - technically the storage bucket url support should be very similar to this - if it helps.

@k0ff33
Copy link

k0ff33 commented Jan 26, 2018

Unfortunately I'm not a mobile app developer but I'm doing my best in trying to debug the issue.

Some of my thoughts:
firebase.storage().refFromURL("gs://my-custom-bucket/path-to.file") can't be used to retrieve files from different bucket as the implementation in the Firebase SDK does not allow to pass a different bucket than the one in the current instance: link to iOS SDK source code.
That is why the app crashes as described in #776.
screen shot 2018-01-26 at 14 19 33

I believe that the only way to support multiple buckets is by implementing the option to pass bucket name in the storage constructor: var storage = firebase.app().storage("gs://my-custom-bucket");.

@Salakar Salakar added help: general General help wanted help: needs-triage Issue needs additional investigation/triaging. labels Feb 16, 2018
@Salakar Salakar self-assigned this Mar 1, 2018
@Salakar Salakar added this to the v4.1.0 Release milestone Mar 1, 2018
@olegdater
Copy link

Any news on this?

Would be really cool to do something like:

var storage = firebase.app().storage("gs://my-custom-bucket");

@Salakar Salakar assigned Salakar and unassigned Salakar Jul 1, 2018
@Salakar
Copy link
Contributor

Salakar commented Jul 1, 2018

Thanks for reporting this issue. This is something we're going to add support for.

We're aware that Storage has fallen behind slightly on React Native Firebase and would like to bring it up to speed again. I will close this issue for now and track it as well as other issues collectively over on the Storage improvements proposal to be addressed in a future release. See #1260

@Salakar Salakar closed this as completed Jul 1, 2018
@Salakar Salakar removed this from the v4.3.0 Release milestone Jul 1, 2018
@Salakar
Copy link
Contributor

Salakar commented Apr 10, 2019

Hey @FacuAcosta @k0ff33 @olegwn - just thought you'd like to know the v6 storage re-write PR is up and well into dev, which includes many improvements including multi-bucket support 🎉

PR & Changelog: #2043

@williamgoodhew
Copy link

williamgoodhew commented Jan 15, 2020

I am getting this same error. I am on react-native-firebase v 5.6.0. Have tried to upgrade to @latest but this seems to be the latest.

In my podfile I have:

pod 'Firebase/Storage', '~> 6.13.0'

React-native version 0.61.5.

I've tried this

const storageRef = firebase.storage('gs://athalens-51eb0-us-rekognition').ref(uid)

    storageRef.put(uri)
      .then(() => {
        dispatch({ type: SET_SELFIE });
      })
      .catch(error => {
        console.log(error);
      });

and this

const storageRef = firebase.app()storage('gs://athalens-51eb0-us-rekognition').ref(uid)

    storageRef.put(uri)
      .then(() => {
        dispatch({ type: SET_SELFIE });
      })
      .catch(error => {
        console.log(error);
      });

I know it says upgrade to v6 but not sure why npm install @latest is only doing v5.6.0

@mikehardy
Copy link
Collaborator

Ah - that is because when RNFB moved from v5 to v6 it also changed packaging style, so @latest of the package react-native-firebase is 5.6.0, but if you want v6 you install different packages - now they look like @react-native-firebase/app + @react-native-app/storage etc (modules all split out)

@williamgoodhew
Copy link

williamgoodhew commented Jan 15, 2020 via email

@mikehardy
Copy link
Collaborator

I believe you'd want this doc: https://invertase.io/oss/react-native-firebase/migrating-to-v6

@amitiwary999
Copy link

setting bucket in storage is not working. I already migrated to v6. I tried storage('gs://bucket_name') but it's not working.

@Mavenic
Copy link

Mavenic commented Apr 23, 2020

Same for me.
Getting the following error:

Error: "firebase.storage(app)" arg expects a FirebaseApp instance or undefined.
Ensure the arg provided is a Firebase app instance; or no args to use the default Firebase app.

firebaseModuleWithApp
    namespace.js:138:10
<unknown>
    index.bundle?platform=ios&dev=true&minify=false:221989:43
loadModuleImplementation
    require.js:321:4

@BrianL3
Copy link

BrianL3 commented May 11, 2023

Still getting this error, using
"@react-native-firebase/storage": "16.7.0"

How are you supposed to use non-default buckets?

@zeevl
Copy link

zeevl commented Dec 31, 2024

I finally got this to work by doing

storage().refFromURL('gs://other-bucket/path')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help: general General help wanted help: needs-triage Issue needs additional investigation/triaging. plugin: storage Firebase Cloud Storage
Projects
None yet
Development

No branches or pull requests