gpt4 book ai didi

android - 使用 URL 从 Firebase 存储中删除文件

转载 作者:太空宇宙 更新时间:2023-11-03 11:32:44 25 4
gpt4 key购买 nike

我正在尝试使用文件 URL 从 Firebase 存储中删除文件。我的问题是无法解析 getReferenceFromUrl()。

此处示例代码:

 StorageReference mStorageRef;
String storageurl = "http:sample"
mStorageRef = FirebaseStorage.getInstance().getReference();
StorageReference ref2 = mStorageRef.getReferenceFromUrl(storageurl);
ref2.delete().addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
// File deleted successfully
Toast.makeText(getContext(), "file deleted", Toast.LENGTH_SHORT).show();
Log.d(TAG, "onSuccess: deleted file");
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Uh-oh, an error occurred!
Log.d(TAG, "onFailure: did not delete file");
}
});

最佳答案

 StorageReference storageReference = FirebaseStorage.getInstance().getReferenceFromUrl("https://firebasestorage.googleapis.com/v0/b/***********************-5fac-45b6-bbda-ed4e8a3a62ab");
storageReference.delete().addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
// File deleted successfully
Log.e("firebasestorage", "onSuccess: deleted file");
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Uh-oh, an error occurred!
Log.e("firebasestorage", "onFailure: did not delete file");
}
});

关于android - 使用 URL 从 Firebase 存储中删除文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45103085/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com