我想将pdf文件上传到Firebase存储,而不是在回收器视图中显示这些文件以下载它。
我有很多方法可以保存URL并将其放入recyclerview以下载文件。但是它不起作用,因为它没有保存网址,而是类似“ com.google.android.gms.tasks.zzu@4284dee0”之类的
final String filename = System.currentTimeMillis()+"";
final StorageReference ref = mstorage.getReference(); // returns path and save in obj variable
ref.child("Files").child(filename).putFile(pdfuri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
String url = ref.child("Files").child(filename).getDownloadUrl().toString();
dbRef = databse.getReference();
dbRef.child("Files").child(filename).child("url").setValue(url).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
String titleview = title.getText().toString();
String inroview = intro.getText().toString();
dbRef.child("Files").child(filename).child("Title").setValue(titleview);
dbRef.child("Files").child(filename).child("Intro").setValue(inroview);
if (task.isSuccessful()){
Toast.makeText(UploadProposal.this, "file uploaded", Toast.LENGTH_SHORT).show();
}
else Toast.makeText(UploadProposal.this, "not uploaded", Toast.LENGTH_SHORT).show();
}
});
}
})