简体   繁体   English

如何使用 Firebase 创建二维码?

[英]How can I create a QR code with Firebase?

Is it possible to create a QR code with Firebase?是否可以使用 Firebase 创建二维码?

I'd like to create a QR code for sharing pdf files with other people.我想创建一个 QR 码来与其他人共享 pdf 文件。 It seems the Firebase has such functions but I couldn't figure it out where to generate the code...似乎 Firebase 有这样的功能,但我无法弄清楚在哪里生成代码......

Firebase ML-Kit has a barcode scanning API but Firebase does not have a way to create/generate QR codes. Firebase ML-Kit 具有条码扫描 API,但 Firebase无法创建/生成 QR 码。

See Firebase ML-Kit: https://firebase.google.com/docs/ml-kit/read-barcodes请参阅 Firebase ML-Kit: https ://firebase.google.com/docs/ml-kit/read-barcodes

Firebase integrates Google Cloud Functions and Cloud Storage. Firebase 集成了谷歌云功能和云存储。 A straightforward way to generate a QR code could be writing a cloud function that takes the input of your call from Firebase, writes the QR code image to your Firebase connected cloud storage, and then returns the URI of the image.生成 QR 码的一种直接方法是编写一个云 function,它从 Firebase 获取您的调用输入,将 QR 码图像写入您的 Firebase 连接的云存储,然后返回图像的 URI。

Firebase Cloud Functions "provides a way to extend the behavior of Firebase and integrate Firebase features through the addition of server-side code." Firebase Cloud Functions“提供了一种方法来扩展 Firebase 的行为并通过添加服务器端代码集成 Firebase 功能。” source 来源

So, unlike GCP Cloud Functions that can be written in multiple languages, you typically will write Typescript or Javascript only on Firebase Functions.因此,与可以用多种语言编写的 GCP 云函数不同,您通常只会在 Firebase 函数上编写 Typescript 或 Javascript。

Example QR Code Generation Code QR码生成代码示例

Example Code for node.js示例代码node.js

// index.js -> bundle.js
var QRCode = require('qrcode')
var canvas = document.getElementById('canvas')

QRCode.toCanvas(canvas, 'sample text', function (error) {
  if (error) console.error(error)
  console.log('success!');
})

Documentation References文档参考

npm QR Code Generator Package npm 二维码生成器 Package

Firebase Functions Getting Started Guide Firebase 函数入门指南

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM