[英]Delete file from firebase using files download URI?
How to delete file from firebase storage? 如何从Firebase存储中删除文件? I'm having files only download URI(String), how can I delete file from fire-base storage?
我只有下载URI(String)的文件,如何从火源存储中删除文件? I tried to parse my download string to uri and tried to reference my storage reference to that uri, but it didn't worked
我试图将我的下载字符串解析为uri,并尝试将存储引用引用到该uri,但是它没有用
private void image_delete(int i){
for(;i<=3;i++){
image_path[i]=image_path[i+1];
if(image_path[i+1]==null)
img[i].setImageResource(R.drawable.camera);
else
Picasso.get().load(image_path[i+1]).into(img[i]);
image_path[i]=image_path[i+1];
img[i+1].setImageResource(R.drawable.camera);
if(image_path[i+1]==null)
break;
}
if(i!=4)
image_body[i+1].setVisibility(View.GONE);
image_path[i]=null;
storageReference=FirebaseStorage.getInstance().getReference();
storageReference.child("Pets").child(image_path[i].substring(image_path[i].indexOf("/Pets")+4,image_path[i].length()));
storageReference.delete();
upload_status.setText("");
}
To delete any file from Firebase Storage using URL : 要使用URL从Firebase存储中删除任何文件,请执行以下操作:
String url= "Chat-Images/1498804025000.png";
StorageReference storageReference =
FirebaseStorage.getInstance().getReference().child(url);
storageReference.delete().addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
Log.d(TAG, "onSuccess: deleted file successfully");
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
Log.d(TAG, "onFailure: File is not delete!");
}
});
Orginal answer: https://stackoverflow.com/a/45103937/9093630 原始答案: https : //stackoverflow.com/a/45103937/9093630
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.