小编ABC*_*ABC的帖子

Firebase / Cloud Function 非常慢

我有一个执行以下操作的 Firebase 云函数:

const firestore = require('firebase-admin')
const functions = require('firebase-functions')
const regex = require('../../utils/regex')

exports = module.exports = functions.https.onCall((data, context) => {
  if (!context.auth) {
    throw new functions.https.HttpsError('failed-precondition', 'The function must be called while authenticated.')
  }

  if (!data['displayName']) {
    throw new functions.https.HttpsError('failed-precondition', 'An display name must be provided.')
  }

  if (!regex.noSpecialCharactersExceptSpace.test(data['displayName'])) {
    throw new functions.https.HttpsError('input-validation-failed', 'Your display name cannot have special characters in it.')
  }

  return firestore.firestore().collection('profiles').doc(context.auth.uid)
    .update({
      displayName: data['displayName']
    })
    .then(() => {
      console.info('Successful public profile update user='+ …
Run Code Online (Sandbox Code Playgroud)

javascript firebase google-cloud-functions google-cloud-firestore

5
推荐指数
0
解决办法
1777
查看次数

`firebase.functions().httpsCallable` 如何将文件提交给 `functions.https.onCall`?

背景:

  1. 我们希望允许用户将文件上传到我们的网站
  2. 文件在写入 Cloud Storage 之前需要经过验证和修改
  3. 在允许用户上传文件之前,我们还需要对用户进行身份验证
  4. 而且,我们需要在将文件写入 Cloud Storage 之前执行一些 Firestore 调用

规格:

  • 我们正在使用前端调用 Cloud Functions firebase.functions().httpsCallable
  • 后端使用 functions.https.onCall

题:

如何firebase.functions().httpsCallable提交文件functions.https.onCall

先感谢您。

ABC。

firebase google-cloud-functions

5
推荐指数
1
解决办法
1952
查看次数

如何在编译时删除未使用的代码?

我们已经构建了一个我们很多人都使用的Go包.

它是使用标准import ("package-name")方法导入的.

但是在编译时,我们所有的实用程序,包括非常小的实用程序,最终都是非常大的二进制文件.

我们已经提取了实用程序中的所有字符串,并发现整个包正在编译到每个实用程序中.包括那些实用程序未使用的函数.

编辑1:

感谢回答这个问题的人们.

这是我们所看到的:

main.go

package main

import "play/subplay"

func main() {
    subplay.A()
}
Run Code Online (Sandbox Code Playgroud)

播放/ subplay.go

package subplay

func A() {
    fmt.Printf("this is function A()")
}

func B() {
    fmt.Printf("secret string")
}
Run Code Online (Sandbox Code Playgroud)

函数B()永远不会被调用.然而,在构建二进制文件之后,我们在main.exe中找到字符串"secret string".

如何在编译时从Go程序中删除未使用的代码?

compilation go compiler-optimization

3
推荐指数
1
解决办法
1695
查看次数