我想将我的android设备的本地文件上传到Firebase存储。
它成功运行。
但是从不调用addOnSuccessListener和addOnFailureListener。
你能让我知道为什么吗?
======================
public void uploadFiles(){
saveState("uploadFiles");
StorageReference mStorageRef;
mStorageRef = FirebaseStorage.getInstance().getReference();
saveState("Firebase initialize");
String dirName = Environment.getExternalStorageDirectory().getAbsolutePath();
dirName += "/Temp";
File file = new File(dirName);
files = file.listFiles();
for (i = 0; i < files.length; i++) {
if (files[i].isFile() && getFileExtension(files[i]).equals(".3GP")) {
Uri uri = Uri.fromFile(files[i]);
StorageReference filepath = mStorageRef.child("Record").child(files[i].getName());
uploadTask = filepath.putFile(uri);
uploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
saveState("onSuccess " + files[i].getName());
}
});
uploadTask.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
saveState("onFailure " + files[i].getName());
}
});
saveState("Success to delete and upload upload " + files[i].getName());
files[i].delete();
}
}
}