Tag: firebase storage

上传到Firebase存储时,如何使用Cloud Functions for FIrebase获取mp3文件的持续时间

我正在为一个舞蹈应用程序build立一个音乐库。 目前我有一个云端function,当一个mp3file upload到Firebase存储时自动创build一个数据库实例,我仍然需要以某种方式获取该mp3文件的持续时间,并将该信息存储在数据库中。 我是新来的JavaScript和第一次做node.js,一些来源指向使用MP3元数据,我没有经验玩任何一个。 一些帮助将不胜感激。

通过云端function检索Firebase存储图像链接

如何通过云端function检索Firebase中存储的图片的下载链接? 我已经尝试了各种各样的变化,包括下一个: exports.getImgs = functions.https.onRequest((req, res) => { var storage = require('@google-cloud/storage')(); var storageRef = storage.ref; console.log(storageRef); storageRef.child('users/user1/avatar.jpg').getDownloadURL().then(function(url) { }); });

Firebase:使用云端function删除Cloud Starage中的文件

我尝试使用Cloud Functions从删除条目中的Cloud Storage删除与Realtime Database某些特定条目相关的所有文件。 我的function看起来像休闲: exports.onDeleteRequest = functions.database.ref('/requests/{requestid}/').onDelete(event => { const storage = functions.config().firebase.storageBucket; const userId = event.data.previous.child('uid').val(); const requestId = event.params.requestid; const path = storage + '/photos/' + userId + '/' + requestId; console.log('path: ', path); return gcs.bucket(path).delete().then(function() { console.log("Files removed"); }).catch(function(error) { console.error("Failed removing files", error); }); }); 但是,我继续在日志中出现以下错误: Failed removing files { […]

Firebase存储:上传后不显示图片文件types。 我如何使用图像?

当我使用谷歌云或multer-gcs这样的npm软件包将file upload到firebase存储桶(使用谷歌云端存储)时,文件就会被上传。 但是,该文件不显示和图像types(MIME)。 另外,如何在我的node.js应用程序中使用图像? 以下是将图片上传到Firebase存储区的代码。 用multer来处理file upload var path = require('path'); var multer = require('multer'); var gcs = require( 'multer-gcs' ); var storage = gcs({ filename : function( req, file, cb ) { cb( null, file.fieldname + '-' + Date.now() + path.extname(file.originalname).toLowerCase()); }, bucket : 'p****n-bcXX3.appspot.com', // Required : bucket name to upload projectId : […]

使用Firebasefunction更新存储更改上的Firebase数据库

我试图在我的Android应用程序中实现configuration文件图片function。 所以我使用了来自Firebase的“ 生成缩略图”样本。 所以每当我上传一个完整大小的图片,它会为我生成缩略图。 但是我想要在缩略图生成后更新我的实时数据库中的缩略图的URL。 const functions = require('firebase-functions'); const mkdirp = require('mkdirp-promise'); const gcs = require('@google-cloud/storage')(); const spawn = require('child-process-promise').spawn; const LOCAL_TMP_FOLDER = '/tmp/'; // Max height and width of the thumbnail in pixels. const THUMB_MAX_HEIGHT = 100; const THUMB_MAX_WIDTH = 100; // Thumbnail prefix added to file names. const THUMB_PREFIX = 'thumb_'; /** […]

在Google云端存储中使用nodejs gcloud api移动/重命名文件夹

我正尝试使用gcloud api重命名或移动Google云端存储中的文件夹。 类似的问题解释了如何删除文件夹: 使用nodejs gcloud api删除Google云端存储中的文件夹 但是,如何重命名一个文件夹? 或移动到另一个path?

在NodeJS服务器端保护Firebase存储的外部链接

我在生成外部链接到存储在我的Firebase存储分区中的文件时遇到问题。 我现在正在使用Google云端存储,并使用此库(基于此答案)为常规存储桶生成外部链接,但在Firebase分配的存储桶上使用该库似乎不起作用。 我无法生成任何安全的HTTPS链接,并继续获取证书validation错误NET::ERR_CERT_COMMON_NAME_INVALID指出我的连接不是私有的。 如果我从HTTPS中删除“S”,则链接起作用。 注意:使用相同的凭据和私钥为我的项目中的其他存储桶生成链接,工作得很好。 只有Firebase存储分区拒绝接受我的签名…

如何使用Firebase云function存储制作文件夹

我怎样才能使文件夹“职位”? 存储桶 – > gs://app.appspot.com/posts 码 exports.generateThumbnail = functions.storage.object() .onChange(event => { const object = event.data const filePath = object.name const fileName = filePath.split('/').pop() const fileBucket = object.bucket; const bucket = gcs.bucket(fileBucket) const tempFilePath = `/posts/${fileName}` return bucket.file(filePath).download({ destination: tempFilePath }) .then(() => { console.log('image downloaded locally to', tempFilePath) return spawn('convert', [tempFilePath, '-thumbnail', '400×400>', tempFilePath]) […]

从Firebasefunction(节点)上传时,Firebase存储文件types未设置

通过Firebase函数(节点)将转换后的图像(.jpg)上传到谷歌存储时,我在元数据选项中设置了contentType。 return bucket.file(filePath).download({destination: tempFilePath}) .then(() => { console.log('Image downloaded locally to', tempFilePath); // Generate a thumbnail using ImageMagick. return spawn('convert', [tempFilePath, '-thumbnail', '200×200>', tempFilePath]) }) .then(() => { console.log('Thumbnail created at', tempFilePath); // Add a 'thumb_' prefix to thumbnails file name. That's where we'll upload the thumbnail. const thumbFilePath = filePath.replace(/(\/)?([^\/]*)$/, `$1thumb_$2`); // Uploading the […]

Firebasefunction可以在使用NodeJS从数据库中删除对象时从存储中删除文件

我是NodeJS的新手,我正在尝试为Firebase的云端函数编写下一个方法。 我正在努力实现的是: 当用户从Firebase DB中移除Photo对象时,该function应该被触发; 该代码应该从对应于Photo obj的存储中移除文件对象。 这些是我的Firebase数据库结构: 照片/ {userUID} / {} photoUID { "dateCreated": "2017-07-27T16:40:31.000000Z", "isProfilePhoto": true, "isSafe": true, "uid": "{photoUID}", "userUID": "{userUID}" } Firebase存储格式: 照片/ {userUID} / {} photoUID .PNG 和我正在使用的NodeJS代码: const functions = require('firebase-functions') const googleCloudStorage = require('@google-cloud/storage')({keyFilename: 'firebase_admin_sdk.json' }) const admin = require('firebase-admin') const vision = require('@google-cloud/vision')(); admin.initializeApp(functions.config().firebase) exports.sanitizePhoto = functions.database.ref('photos/{userUID}/{photoUID}') .onDelete(event […]