此getDownloadUrl()
方法在更新为
'com.google.firebase:火力储存:15.0.2'
官方网站上没有任何其他方式可以实现网址,那么有什么办法以非弃用的方式实现网址?
/** @deprecated */
@Deprecated
@Nullable
public Uri getDownloadUrl() {
StorageMetadata var1;
return (var1 = this.getMetadata()) != null ? var1.getDownloadUrl() : null;
}
}
答案 0 :(得分:6)
在文档中它说:
getDownloadUrl()
类的getDownloadUrls()
和StorageMetadata
方法现已弃用。请改用getDownloadUrl()
中的StorageReference
。
因此,您需要使用getDownloadUrl()
StorageReference
public Task<Uri> getDownloadUrl ()
使用可撤销令牌异步检索长期下载URL。这可用于与其他人共享文件,但如果需要,可由Firebase控制台中的开发人员撤消。
此处提供更多信息:
答案 1 :(得分:4)
final StorageReference filePath = mImageStore.child("profile_images").child("full_image").child(userId + ".jpg");
filePath.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
//Bitmap hochladen
uploadBitMap(uri.toString());
}
});strong text
或
final UploadTask uploadTask = thumb_file.putBytes(thumb_bite);
uploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
//Url laden
taskSnapshot.getStorage().getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
Map imageUrls = new HashMap();
imageUrls.put("image", fullImageUrl);
imageUrls.put("thumb_image", uri.toString());
//In database
mAlarmsDatabaseReference.updateChildren(imageUrls).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
//Progressbar beende + Bild wieder anzeigen
progressBar.setVisibility(View.GONE);
circleProfilePicture.setVisibility(View.VISIBLE);
if(task.isSuccessful()){
Toast.makeText(SettingsActivity.this, getResources().getString(R.string.ProfilbildUpdate), Toast.LENGTH_SHORT).show();
}else{
Toast.makeText(SettingsActivity.this, "FAILED", Toast.LENGTH_SHORT).show();
}
}
});
}
});
}
});
答案 2 :(得分:0)
最终UploadTask uploadTask = thumb_file.putBytes(thumb_bite); uploadTask.addOnSuccessListener(new OnSuccessListener(){ @Override 公共无效onSuccess(UploadTask.TaskSnapshot taskSnapshot){
//Url laden
taskSnapshot.getStorage().getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
Map imageUrls = new HashMap();
imageUrls.put("image", fullImageUrl);
imageUrls.put("thumb_image", uri.toString());
//In database
mAlarmsDatabaseReference.updateChildren(imageUrls).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
//Progressbar beende + Bild wieder anzeigen
progressBar.setVisibility(View.GONE);
circleProfilePicture.setVisibility(View.VISIBLE);
if(task.isSuccessful()){
Toast.makeText(SettingsActivity.this, getResources().getString(R.string.ProfilbildUpdate), Toast.LENGTH_SHORT).show();
}else{
Toast.makeText(SettingsActivity.this, "FAILED", Toast.LENGTH_SHORT).show();
}
}
});
}
});
}
});