我得到了这个例外:
将音频文件从Android上传到Firebase存储时发生了StorageException。 发生未知错误,请检查HTTP结果代码和服务器响应的内部异常。代码:-13000 HttpResult:0
。我的代码是:
private static StorageReference storageReference;
private static DatabaseReference mDatabase;
// inside the method
storageReference = FirebaseStorage.getInstance().getReference();
mDatabase = FirebaseDatabase.getInstance().getReference("Post/");
final ProgressDialog progressDialog = new ProgressDialog(context);
progressDialog.setTitle("Uploading Preview File");
progressDialog.show();
StorageReference sRef = storageReference.child("rahat/");
sRef.putFile(filePathUri)
.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
progressDialog.dismiss();
Toast.makeText(context, "File Uploaded ", Toast.LENGTH_LONG).show();
Upload upload = new Upload("Preview", taskSnapshot.getDownloadUrl().toString());
String uploadId = mDatabase.push().getKey();
mDatabase.child(uploadId).setValue(upload);
}
})
.addOnFailureListener(new OnFailureListener()
{
@Override
public void onFailure(@NonNull Exception exception) {
progressDialog.dismiss();
//Toast.makeText(context, exception.getMessage(), Toast.LENGTH_LONG).show();
Log.v("error", exception.toString());
}
})
.addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>()
{
@Override
public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
//displaying the upload progress
double progress = (100.0 * taskSnapshot.getBytesTransferred()) / taskSnapshot.getTotalByteCount();
progressDialog.setMessage("Uploaded " + ((int) progress) + "%...");
}
});
我的手机上安装了最新版本的Google Play服务。
答案 0 :(得分:0)
只需更新您的Firebase存储依赖项版本