400当我尝试删除目录时,FirebaseStorage始终返回错误,例如以下内容始终返回错误400.
let storageRef = FIRStorage.storage().reference().child("path/to/directory")
storageRef.deleteWithCompletion { (error) in
print("error: \(error)") // always prints error code 400
}
Run Code Online (Sandbox Code Playgroud)
但是,删除文件工作正常,例如不会返回错误:
let storageRef = FIRStorage.storage().reference().child("path/to/file.jpg")
storageRef.deleteWithCompletion { (error) in
print("error: \(error)") // works fine, error is nil
}
Run Code Online (Sandbox Code Playgroud)
我在这里做错了什么?我不认为它不受FirebaseStorage的支持,因为从目录中逐个删除文件会非常蹩脚(特别是如果所述目录有100或1000个).
我想使用 Node js 删除 firebase 存储中的文件夹,因为这是一个 firebase 函数。
例如 :
storageRef.child(child1).child(child2).delete();
Run Code Online (Sandbox Code Playgroud)
类似这样的东西,但 firebase 文档没有说明任何信息。
还有一个问题:当初始化存储文档时,节点js需要我的管理json,但实时数据库不需要这个奇怪的原因?
node.js firebase google-cloud-functions firebase-storage firebase-admin
我正在尝试删除 firebase 存储中文件夹中的内容:
我尝试使用以下函数来做到这一点:
let storageRef = Storage.storage().reference().child((Auth.auth().currentUser?.uid)!).child("post:\(selectedPost.media[0].postID!)/")
// let postRef = storageRef.child("image.png")
// Delete the file
storageRef.delete { error in
if error != nil {
// Uh-oh, an error occurred!
print("FAIL DELETING POST FROM STORAGE")
} else {
// File deleted successfully
print("SUCCESS DELETING STORAGE REF TO POST!")
}
}
Run Code Online (Sandbox Code Playgroud)
问题是它没有这样做。它打印失败:
Optional(Error Domain=FIRStorageErrorDomain Code=-13010 "Object LWzvQXAoX3Ov9DW9LopWFFjJBJY2/post:579755726 does not exist." UserInfo={object=LWzvQXAoX3Ov9DW9LopWFFjJBJY2/post:579755726, ResponseBody={
"error": {
"code": 404,
"message": "Not Found. Could not delete object",
"status": "DELETE_OBJECT"
}
}
Run Code Online (Sandbox Code Playgroud)
检查存储时,我可以清楚地看到该文件夹确实存在。
怎么了?