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

bug: Unable to upload file to Firebase Cloud Storage #578

Closed
5 of 16 tasks
shaktis110 opened this issue Mar 8, 2024 · 3 comments · Fixed by #579
Closed
5 of 16 tasks

bug: Unable to upload file to Firebase Cloud Storage #578

shaktis110 opened this issue Mar 8, 2024 · 3 comments · Fixed by #579
Labels
bug/fix Something isn't working package: storage platform: android Android platform
Milestone

Comments

@shaktis110
Copy link

shaktis110 commented Mar 8, 2024

Plugin(s)

  • Analytics
  • App
  • App Check
  • Authentication
  • Crashlytics
  • Cloud Firestore
  • Cloud Messaging
  • Cloud Storage
  • Performance
  • Remote Config

Version

5.4.1

Platform(s)

  • Android
  • iOS
  • Web

Current behavior

Attempting to upload an image file to Firebase Cloud Storage, encountering an error:

Error message: "Attempt to invoke virtual method 'java.lang.String com.getcapacitor.JSObject.getString(java.lang.String)' on a null object reference"

current setup :
uploadProfileFile = async () => {
await FirebaseStorage.uploadFile(
{
path: 'images/17852709929324920.jpeg',
uri: 'file:///data/user/0/com.testing.cloudstorage/cache/17852709929324920.jpeg',
},
(event, error) => {
if (error) {
console.log(error);
console.log('error');
} else if (event?.completed) {
console.log('upload complete')
}
}
);
};

I've tried an alternative method to verify the setup, and it's functioning correctly. I'm receiving responses from Firebase storage.

listFiles = async () => {
const { items } = await FirebaseStorage.listFiles({
path: 'images',
});
return items;
};

Expected behavior

The Firebase Cloud Storage upload feature should function as intended, allowing users to seamlessly upload files to the designated storage location.

Reproduction

https://github.com/shaktis110/firebase-storage-test-app.git

Steps to reproduce

(1) Open the Application
(2) Click on the Avatar Icon
(3) Choose Image Source Select the option to upload an image from either the gallery or camera.
(4) Error in Logcat

Other information

Device : Android 13

Attempt to invoke virtual method 'java.lang.String com.getcapacitor.JSObject.getString(java.lang.String)' on a null object reference
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.getcapacitor.JSObject.getString(java.lang.String)' on a null object reference
at io.capawesome.capacitorjs.plugins.firebase.storage.FirebaseStorageHelper.buildStorageMetadata(FirebaseStorageHelper.java:12)
at io.capawesome.capacitorjs.plugins.firebase.storage.classes.options.UploadFileOptions.(UploadFileOptions.java:23)
at io.capawesome.capacitorjs.plugins.firebase.storage.FirebaseStoragePlugin.uploadFile(FirebaseStoragePlugin.java:204)
at java.lang.reflect.Method.invoke(Native Method)
at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:138)
at com.getcapacitor.Bridge.lambda$callPluginMethod$0(Bridge.java:800)
at com.getcapacitor.Bridge.$r8$lambda$ehFTi5f4HhVNFKTbCKAYDkpQYRA(Unknown Source:0)
at com.getcapacitor.Bridge$$ExternalSyntheticLambda3.run(Unknown Source:8)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.os.HandlerThread.run(HandlerThread.java:67)

Capacitor doctor

💊 Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: 5.7.2
@capacitor/core: 5.7.2
@capacitor/android: 5.7.2
@capacitor/ios: 5.7.2

Installed Dependencies:

@capacitor/ios: not installed
@capacitor/cli: 5.7.2
@capacitor/android: 5.7.2
@capacitor/core: 5.7.2

[success] Android looking great! 👌

Before submitting

  • I have read and followed the bug report guidelines.
  • I have attached links to possibly related issues and discussions.
  • I understand that incomplete issues (e.g. without reproduction) are closed.
@shaktis110 shaktis110 added bug/fix Something isn't working needs: triage labels Mar 8, 2024
@robingenz
Copy link
Member

Thank you! I will fix this.

@robingenz robingenz added this to the v6.0.0 milestone Mar 8, 2024
@robingenz
Copy link
Member

@shaktis110 Please give this dev build a try:

npm i @capacitor-firebase/storage@5.4.1-dev.b12767c.1709972019

@shaktis110
Copy link
Author

working thanks @robingenz

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug/fix Something isn't working package: storage platform: android Android platform
Projects
None yet
2 participants