react-native-firestack icon indicating copy to clipboard operation
react-native-firestack copied to clipboard

No downloadUrl from the response of storage.uploadFile with iOs

Open bitcoinvsalts opened this issue 8 years ago • 10 comments

but it is present with android

bitcoinvsalts avatar Oct 12 '16 02:10 bitcoinvsalts

the other thing downloadUrl does not work with android, it gives me permission error.

so I need to have platform specific code.

here is my current solution that is not ideal:

firebaseApp.storage.uploadFile(`posts/${uid}/${imageName}`, source, {
                contentType: 'image/jpeg',
                contentEncoding: 'base64',
              })
              .then((res) => {
                console.log('The file has been uploaded')
                console.log(res);
                console.log("----------");
                console.log(`posts/${uid}/${imageName}`);
                firebaseApp.storage.ref(`posts/${uid}/${imageName}`).downloadUrl()
                .then((res) => {
                  console.log("--- if iOS this should work ---");
                  console.log(res.url);
                 ...
                })
                .catch((error) => {
                  console.log("--- not working with android ---");
                  console.log(error);
                  console.log("so we use the previous res.downloadUrl");
                  console.log(res.downloadUrl);
                  ...
                })

bitcoinvsalts avatar Oct 12 '16 03:10 bitcoinvsalts

Just to clarify, the issue is that the res.url exists on ios and not on Android?

auser avatar Oct 15 '16 22:10 auser

res.url exists on android res.url does not exist on ios

running npm v 2.3.3 confirmed just now

tegument avatar Nov 17 '16 15:11 tegument

I submitted a PR for this: https://github.com/fullstackreact/react-native-firestack/pull/148

tegument avatar Nov 18 '16 14:11 tegument

Awesome. Will take a look shortly

auser avatar Nov 18 '16 14:11 auser

I have the same problem on Android.

Method on iOS works fine, but on Android: error: {code: 1, message: "User does not have permission to access this object."}

On iOS this: const storageRef = firestack.storage.ref(${path}/${name}) storageRef.firestack.configured == true But on Android is false.

Maybe is because on Android use GoogleService-Info.plist and in Android use javascrpit config.

My android config is ok?

const configurationOptions = {
  debug: false,
  APIKey: Constants.API_Firebase_ApiKey,
  storageBucket: Constants.API_Firebase_StorageBucket,
  databaseURL: Constants.API_Firebase_DatabaseURL,  
};

const initialState = {
  firebaseApp: new Firestack(configurationOptions),
};

On debug mode, at configure: [info] Native error occurred while calling configure: FirebaseApp name [DEFAULT] already exists!

I init Firestack on Reducer initialState, like on iOS, but on iOS emualtor it works.

PD: On iOS exist res.url PD2: Thanks for this component!

luisfuertes avatar Dec 05 '16 16:12 luisfuertes

Somebody has solved this issue? I cant get downloadUrl on Android because i havnt permission.. but on iOS works fine.

@auser can u help me?

luisfuertes avatar Jan 03 '17 12:01 luisfuertes

double check that you have setup the Firebase Android API: https://firebase.google.com/docs/android/setup The google-services.json needs to be added to the /app directory and the android project files need to be updated.

tegument avatar Jan 05 '17 21:01 tegument

I am getting the same issue "FirebaseApp name [DEFAULT] already exists!", full error from react native:

firestack | [info] Native error occurred while calling configure Object {msg: "FirebaseApp name [DEFAULT] already exists!"}

This occurs just after calling this.firestack = new Firestack({ debug: true });

I do have the google-services.json file in the /app folder, and have Google Play services installed. I am using API 23 and the latest RN & Firstack.

Looking around the internet, it seems this error occurs because a second instance of the firebase app is being created by RN/Firestack. I have this error whether using the google-services.json or providing the constants in the configuration as @luisfuertes did.

Any help would be appreciated. Let me know if I should make this it's own issue, only putting it here because it seems others in this stream have run into this error.

SteffeyDev avatar Jan 10 '17 06:01 SteffeyDev

I have the same issue on Android as well...

vivekmago avatar Jan 16 '17 02:01 vivekmago