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

Android Firebase 11.2.0 MetaData causing "StorageException, an unknown error has occured" #116

Closed
mitchtabian opened this issue Sep 30, 2017 · 6 comments

Comments

@mitchtabian
Copy link

I tested with 11.0.4 and it works fine. 11.2.0 up to 11.4.0 cause the error. The error is at the bottom. There is a heading labeled "Error Message"

Here are the details:

  1. I'm authenticated and trying to upload an image to storage. The problem isn't the image but here it is https://firebasestorage.googleapis.com/v0/b/fir-webapp-b2c06.appspot.com/o/b7a1665.jpg?alt=media&token=a2ab1033-6528-450b-a369-2fbdbaa36201
  2. The image gets to about 50% upload progress and then the onFailureListener catches a failure.
  3. Using version 11.0.4 works and using 11.2.0 or anything higher doesn't
  4. I check the change logs here https://firebase.google.com/support/release-notes/android and it seems there was a change made regarding meta data.
  5. After reading the change log I removed the meta data object from the "putBytes" method below. I reran the app and the upload worked. If you're confused this is what I did:
    Original code:

    UploadTask uploadTask = storageReference.putBytes(mBytes, metadata);
    Changed to:
    UploadTask uploadTask = storageReference.putBytes(mBytes);

Hypothesis:

Whatever change was introduced regarding the meta data in 11.2.0 is causing an issue.

Relevant code:

My Storage reference:
StorageReference storageReference = FirebaseStorage.getInstance().getReference() .child("photos/users/" + FirebaseAuth.getInstance().getCurrentUser().getUid() + "/profile_image");
My Meta Data:
StorageMetadata metadata = new StorageMetadata.Builder() .setContentType("image/jpg") .setContentLanguage("English") .setCustomMetadata("Mitch's special meta data", "JK nothing special here") .setCustomMetadata("location", "Iceland") .build();

My UploadTask:
UploadTask uploadTask = storageReference.putBytes(mBytes, metadata);

Then OnSuccessListener and so on...

Error Message

StorageException has occurred. An unknown error occurred, please check the HTTP result code and inner exception for server response. Code: -13000 HttpResult: 400 09-30 12:44:06.048 31582-1094/courses.pluralsight.com.tabianconsulting E/StorageException: The server has terminated the upload session java.io.IOException: The server has terminated the upload session at com.google.firebase.storage.UploadTask.zzcat(Unknown Source) at com.google.firebase.storage.UploadTask.zzcas(Unknown Source) at com.google.firebase.storage.UploadTask.run(Unknown Source) at com.google.firebase.storage.zzs.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818)

@mitchtabian
Copy link
Author

I realized I probably put this in the wrong location. Not really sure where to post I just saw someone else had an error that seemed similar a while back.

@patrickhoh
Copy link

Hi Mitch,
the error is raised because the ContentLanguage must be set to a 2-letter language code defined by ISO 639-1. (E.g. "en"). These two letters must also be lowercase. So neither "English" nor "EN" are valid values. I am sorry that this is currently not documented and gives a very unhelpful error message. I will look into at least updating the documentation.

In 11.0.4 and older versions of the Android SDK, there was a bug when setting the ContentLanguage. In 11.2.0, this bug was fixed and the SDK now correctly sends the content language to the server. We didn't realize at the time that fixing the bug would also lead to the server starting to reject invalid content languages or we would have documented it.

In case someone else reads this: even though this is posted under "quickstart-unity", it is an issue with the Android Firebase Storage SDK. The restriction to ISO 639-1 language codes also exists in the Unity SDK, but there never was a change in behavior.

@mitchtabian
Copy link
Author

That was fast. Thanks Patrick.

@winky12345
Copy link

Hello Mitch.. Please I really need a mentor showing me how to make android apps,please... And I'm having this error of StorageException -1300..I need help..Thank you so much

@raviteja-reddy77
Copy link

hi patrick,

i was also getting same error "StorageException has occurred.
An unknown error occurred, please check the HTTP result code and inner exception for server response."
i created one folder in storage which is storage path.
my android device is HTC one with API 21 5.0.2.
can you please help me...
thank you.

@HamdaanAli
Copy link

Same here I also trying store my file in Firebase Storage but it gives me this error when i run my app on my real device but it is working perfectly on Emulator i don't know how! I am using 11.0.4 version

@firebase firebase locked and limited conversation to collaborators Oct 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants