0
error firebase.storage.UploadTask.<init>(Unknown Source) and firebase.storage.StorageReference.putFile(Unknown Source)
..... 當顯示此錯誤時,則標記ref.putFile(imgUri)。請有人幫助我,我的錯誤發生在哪裏。錯誤firebase.storage.UploadTask。 <init>(Unknown Source)and firebase.storage.StorageReference.putFile(Unknown Source)
//Get the storage reference
StorageReference ref = mStorageRef.child(FB_STORAGE_PATH + System.currentTimeMillis() + "." + getImageExt(imgUri));
//Add file to reference
ref.putFile(imgUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
//Dimiss dialog when success
dialog.dismiss();
//Display success toast msg
Toast.makeText(getApplicationContext(), "Image uploaded", Toast.LENGTH_SHORT).show();
ImageUpload imageUpload = new ImageUpload(txtImageName.getText().toString(), taskSnapshot.getDownloadUrl().toString());
//Save image info in to firebase database
String uploadId = mDatabaseRef.push().getKey();
mDatabaseRef.child(uploadId).setValue(imageUpload);
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
//Dimiss dialog when error
dialog.dismiss();
//Display err toast msg
Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
}
})
.addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
@Override
public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
//Show upload progress
double progress = (100 * taskSnapshot.getBytesTransferred())/taskSnapshot.getTotalByteCount();
dialog.setMessage("Uploaded " + (int) progress + "%");
}
});
} else {
Toast.makeText(getApplicationContext(), "Please select image", Toast.LENGTH_SHORT).show();
}
}