【发布时间】:2019-12-08 10:17:39
【问题描述】:
在我的 Google Cloud Functions 脚本中,我想使用以下代码删除 Google Cloud Storage 文件:
const gcs = require('@google-cloud/storage')()
exports.deletePost = functions.https.onRequest((request, response) => {
if(!context.auth) {
throw new functions.https.HttpsError('failed-precondition', 'The function must be called while authenticated.');
}
const the_post = request.query.the_post;
const filePath = context.auth.uid + '/posts/' + the_post;
const bucket = gcs.bucket('android-com')
const file = bucket.file(filePath)
const pr = file.delete()
});
问题是我还需要在删除存储文件后删除 Google Firebase Firestore 数据库条目。所以我想知道我是否可以在例如delete返回的承诺中做到这一点?
PS : 我没有找到文档
【问题讨论】:
标签: google-cloud-functions google-cloud-storage