Google cloud firestore 如何通过云函数读取Firestore字段中记录的长值
我有以下功能:Google cloud firestore 如何通过云函数读取Firestore字段中记录的长值,google-cloud-firestore,google-cloud-functions,Google Cloud Firestore,Google Cloud Functions,我有以下功能: const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(functions.config().firebase); exports.base64ToImage = functions.firestore .document('documentos/{documentoId}/ocorrencias/{o
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.base64ToImage =
functions.firestore
.document('documentos/{documentoId}/ocorrencias/{ocorrenciasId}')
.onCreate(async (snapshot, context) => {
const ocorrencia = snapshot.data();
const imagemBase64 = ocorrencia.imagemBase64;
console.log('String base64: ', imagemBase64); //here it displays only the first 5000 characters but saves the complete string to Firestore.
});
在firestore中创建新文档时激活此函数,document.b64字段中记录的值为200kb,约为150000个字符,但在尝试读取此值时,仅返回前5000个字符。如何获得Firestore中记录的完整数量。您可能只是遇到了单个日志行长度的限制。我敢肯定,如果你试着用绳子的长度,它会很好。尝试记录字符串的长度,而不是检查它:
console.log(`Length: ${imagemBase64.length}`)
您可能只是在单个日志行的长度上遇到了限制。我敢肯定,如果你试着用绳子的长度,它会很好。尝试记录字符串的长度,而不是检查它:
console.log(`Length: ${imagemBase64.length}`)
Firestore从不截断查询中的任何值。请编辑问题以显示未按预期方式工作的完整代码,包括任何人都可以用来重现问题的步骤。请阅读:@DougStevenson我用完整的代码编辑了我的问题。Firestore从不截断查询中的任何值。请编辑问题以显示未按预期方式工作的完整代码,包括任何人都可以用来重现问题的步骤。请阅读:@DougStevenson我用完整的代码编辑了我的问题。没错,我没有想过要得到字符串长度。非常感谢,现在我将进入下一步,这将是转换为一个文件。但是谢谢你,我的英语很差,很抱歉。没错,我没有想过要知道绳子的长度。非常感谢,现在我将进入下一步,这将是转换为一个文件。但是谢谢你,我的英语很差。