StorageException: An unknown error occurred, please check the HTTP result code and inner exception for server response

前端 未结 13 2030
执念已碎
执念已碎 2021-02-09 20:19

I use Firebase Storage to upfile. But it does not work THIS IS MY CODE.

FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference sto         


        
相关标签:
13条回答
  • 2021-02-09 20:34

    Using putStream() is the the recommended way for most files instead of putFile() (for local files on the device) like so:

    InputStream stream = new FileInputStream(new File(pathToYourFile)));
    
    UploadTask uploadTask = imageFileStorageReference.putStream(stream);
    
    0 讨论(0)
  • 2021-02-09 20:36

    You can't use putFile() with an HTTP type Uri. According to the documentation, you're supposed to use it to upload a local file.

    If you want to upload a file to Storage that exists somewhere else referenced by an HTTP URL, you'll have to download that file first, store it locally, then upload it.

    0 讨论(0)
  • 2021-02-09 20:38

    This Sorted me out, All I needed to do was to update the firebase-storage lib. In my case it was 'com.google.firebase:firebase-storage:16.4.0' and after updating it to 'com.google.firebase:firebase-storage:17.0.0' everything start working fine again.

    0 讨论(0)
  • 2021-02-09 20:42

    May be this is the wrong path bug but in my case resolve this here is the example

    i use this code then i received error

    public static StorageReference getChildProfileStorage(String vid){
        StorageReference storageReference= FirebaseStorage.getInstance().getReference();
        storageReference.child("ParentDataStore").child(CurrentUser.getInstance().getEmail())
                .child("ChildDataStore").child(vid);
    
        return storageReference;
    }
    

    here is the line that solve my problem

    public static StorageReference getStudentProfileStorage(String vid){
        StorageReference storageReference= FirebaseStorage.getInstance().getReference("ParentDataStore")
                .child("StudentDataStore").child(vid).child("profile");
        return storageReference;
    }
    
    0 讨论(0)
  • 2021-02-09 20:44

    For me it working properly if the upload file is no symbols such +, @, #, $ make sure the file name is only number, letters, period, and underscore.

    0 讨论(0)
  • 2021-02-09 20:45

    The key to solving this problem is to enable Storage in the app's permissions. You should follow these steps:

    Settings -> Apps -> AppName -> Permissions -> Enable Storage
    

    Remember that the file should exist on the device.

    0 讨论(0)
提交回复
热议问题