Tag: firebase storage

存储上的Firebasefunction是否存在通配符?

我已成功使用Firebasefunction对我上传到Firebase存储的文件执行操作。 我目前想要做的是通过使用通配符访问我正在推送数据的文件夹,其实现方式与实时数据库+ Firestore相同。 但是,每当我尝试访问这些参数,他们只返回null 。 这不可能吗? 这是我的代码的一个例子: exports.generateThumbnail = functions.storage.object('user-photos/{userId}/{publicOrPrivate}').onChange(event => { const privateOrPublic = event.params.publicOrPrivate; const isPrivate = (event.params.publicOrPrivate == "private"); const userId = event.params.userId; console.log("user id and publicOrPrivate are", userId, privateOrPublic); //"user id and publicOrPrivate are undefined undefined" } 谢谢!

如何使用云端函数删除文件?

当我在Firebase数据库中删除post时,我希望云function可以相应地删除post在Firebase存储中的缩略图。 我的问题是,当我试图删除缩略图我不认为我正确定位图像文件。 这是我所尝试的: const functions = require('firebase-functions') const admin = require('firebase-admin') const gcs = require('@google-cloud/storage')() exports.deletePost = functions.database.ref('Posts/{pushId}').onWrite(event => { const original = event.data.val() const previous = event.data.previous.val() const pushId = event.params.pushId if (original === null) return const filePath = 'Posts/' + pushId + 'thumbnail.jpg' const bucket = gcs.bucket('postsapp-12312') const file = bucket.file(filePath) const pr […]

使用适用于Firebase的Cloud Functions和@ google-cloud / storage删除图片时出现问题

我正在尝试在Fire的Cloud Functions中创build一个脚本,该脚本将对db事件作出反应,并删除其中一个参数(“fullPath”)中具有其path的图像。 这是我使用的代码: 'use strict'; const functions = require('firebase-functions'); const request = require('request-promise'); const admin = require('firebase-admin'); const gcs = require('@google-cloud/storage')({ projectId: 'XXXXXXX', credentials: { // removed actual credentials from here }}); admin.initializeApp(functions.config().firebase); // Deletes the user data in the Realtime Datastore when the accounts are deleted. exports.removeImageOnNodeRemoval = functions.database .ref("images/{imageId}") .onWrite(function (event) { // […]

从使用Cloud Functions for Fire上传的文件获取下载url

在Firebase存储中使用Firebasefunction上传文件后,我想获取文件的下载url。 我有这个 : … return bucket .upload(fromFilePath, {destination: toFilePath}) .then((err, file) => { // Get the download url of file }); 目标文件有很多参数。 即使一个名为mediaLink 。 但是,如果我尝试访问这个链接,我得到这个错误: Anonymous users does not have storage.objects.get access to object … 有人可以告诉我如何获得公共下载url? 谢谢