E / StorageException:发生了StorageException。 发生未知错误,请检查HTTP结果代码和服务器响应的内部异常。 代码:-13000 HttpResult:400
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.zzcyp(Unknown Source)
at com.google.firebase.storage.UploadTask.zzcyo(Unknown Source)
at com.google.firebase.storage.UploadTask.run(Unknown Source)
at com.google.firebase.storage.StorageTask$5.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
E/MainActivity: onFailure sendFileFirebase An unknown error occurred, please check the HTTP result code and inner exception for server response.
这是我为图片上传编写的代码
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageRef = storage.getReferenceFromUrl(Util.URL_STORAGE_REFERENCE).child(Util.FOLDER_STORAGE_IMG);
final String name = DateFormat.format("yyyy-MM-dd_hhmmss", new Date()).toString();
StorageReference imageGalleryRef = storageReference.child(name + "_gallery");
UploadTask uploadTask = imageGalleryRef.putFile(file);
uploadTask.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.e(TAG, "onFailure sendFileFirebase " + e.getMessage());
}
}).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Log.e(TAG, "onSuccess sendFileFirebase");
Uri downloadUrl = taskSnapshot.getDownloadUrl();
FileModel fileModel = new FileModel("img", downloadUrl.toString(), name, "");
ChatModel chatModel = new ChatModel(userModel, "", Calendar.getInstance().getTime().getTime() + "", fileModel);
mFirebaseDatabaseReference.child(CHAT_REFERENCE).push().setValue(chatModel);
}
});