我试图从firebase存储中删除图像。我有一个图像路径,我已经检查过它。它是完全正确的路径,但删除没有发生。这是代码
final StorageReference riversRef = storageRef.child(Profilepath);
riversRef.delete().addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
ref.child(stateName).child(cityName).child("items").child(mobile_cat)
.child(CItemid).setValue(null, new DatabaseReference.CompletionListener() {
@Override
public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) {
menuadapter.notifyDataSetChanged();
UploadCounterMinus();
}
});
lDialog.dismiss();
Toast.makeText(Mobile_items.this.getContext(),"file deleted", Toast.LENGTH_LONG).show();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(Mobile_items.this.getContext(),"somthing happen, try again!!", Toast.LENGTH_LONG).show();
}
});
这是错误
05-10 14:13:36.057 12326-19049/localninjabusinessapp.bhupendra.localninjabusiness E/StorageException: { "error": { "code": 404, "message": "Not Found. Could not delete object" }}
java.io.IOException: { "error": { "code": 404, "message": "Not Found. Could not delete object" }}
at bnp.a(:com.google.android.gms.dynamite_dynamitemodulesc@12529002@12.5.29 (000304-192802242):147)
at bnp.a(:com.google.android.gms.dynamite_dynamitemodulesc@12529002@12.5.29 (000304-192802242):119)
at bnj.onTransact(:com.google.android.gms.dynamite_dynamitemodulesc@12529002@12.5.29 (000304-192802242):8)
at android.os.Binder.transact(Binder.java:361)
at com.google.android.gms.internal.zzed.zzb(Unknown Source)
at com.google.android.gms.internal.zzewv.zzrw(Unknown Source)
at com.google.android.gms.internal.zzewz.zze(Unknown Source)
at com.google.android.gms.internal.zzewo.zza(Unknown Source)
at com.google.firebase.storage.zza.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
虽然我在其他活动中使用相同的代码来删除图片及其正常工作
答案 0 :(得分:0)
实际上,您不能使用对象引用删除存储项目,必须采取 图片/视频网址参考删除存储项目
答案 1 :(得分:0)
您必须检查路径,在这种情况下,请检查以下变量: 个人资料路径
这必须与Firebase中的存储位置相同。
如果您打开Chrome浏览器,则可以在要删除的图像下方看到存储位置。