简体   繁体   English

使用模拟器时可以避免使用实时 Firebase 存储吗?

[英]Can I avoid using live Firebase Storage when using emulators?

as I patiently wait for Firebase storage to be added to the emulators, I was wondering if there is a way I can avoid modifying live storage files and folders when running hosting / functions in the emulator?当我耐心等待将 Firebase 存储添加到模拟器时,我想知道是否有一种方法可以避免在模拟器中运行托管/功能时修改实时存储文件和文件夹?

For example I use the following code to delete all the files in a folder.例如,我使用以下代码删除文件夹中的所有文件。 Last night someone accidentally deleted all the documents in our emulator as part of a test and it deleted all the LIVE storage folders as we use an import of real documents into our emulator昨晚有人不小心删除了我们模拟器中的所有文档作为测试的一部分,当我们使用将真实文档导入我们的模拟器时,它删除了所有 LIVE 存储文件夹

async function deleteStorageFolder(path:string) {
  const bucket = admin.storage().bucket();
  return bucket.deleteFiles({
    prefix: path
  })

Is there any way I can tell firebase to avoid using the production storage APIs when emulators are running?有什么方法可以告诉 firebase 在模拟器运行时避免使用生产存储 API?

I have used the following condition in my function to prevent using firebase storage API when running in emulator:我在我的 function 中使用了以下条件,以防止在模拟器中运行时使用 firebase 存储 API:

if (process.env.FUNCTIONS_EMULATOR == "true") {
  console.log(`Running in emulator, won't call firebase storage`)

} else {
  // Code goes here to run storage APIs
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用node.js应用程序中的内部存储位置从firebase存储中获取DownloadableURL? - How can I get DownloadableURL from firebase storage using the internal storage location in node.js app? 我可以制作一个仅适用于本地 Firebase 模拟器的云 Function 吗? - can I make a Cloud Function that only for local Firebase Emulators? 如何使用 nodejs 和 reactjs 设置 firebase 仿真器? - How to set up firebase emulators using nodejs and reactjs? 如何使用 Firebase 函数获取存储桶中的文件列表 - How can I get a list of files in my storage bucket using Firebase Functions 当我使用 firebase 模拟器和 next.js 时如何使用 firebase-admin 获取 Firestore 数据 - how to get firestore data with firebase-admin when I use firebase emulators and next.js 尝试运行 firebase 仿真器时出现 Java 错误 - Java error when trying to run firebase emulators 如何使用函数从 Firebase 存储中删除文件夹? - How do I delete a folder from Firebase Storage using a function? 我在哪里可以找到 firebase-debug.log 来了解为什么模拟器没有完全关闭? - Where can I find firebase-debug.log to understand why emulators did not cleanly shut down? 上传到Firebase存储时如何使用Cloud Functions for FIrebase获取mp3文件的持续时间 - How to get the duration of a mp3 file using Cloud Functions for FIrebase when uploaded to firebase storage 如何使用 firebase 管理员 sdk 将图像上传到 firebase 存储? - How do I upload an image to firebase storage using firebase admin sdk?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM