[英]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.