safeSearchDetection找不到图像

时间:2018-02-12 17:02:41

标签: node.js firebase types google-cloud-functions

过去36小时我一直坚持这个问题。我正在浏览Firela Cloud Functions的Codelabs教程。 我的应用程序已部署到firebase托管。

当我从根发送图像文件时:

gs://sistema-ximbo.appspot.com

我的功能完美无缺,但是当我将文件发送到images目录时。它不起作用,如何指定目录?

gs://sistema-ximbo.appspot.com/imagens

IMPORTS ****

export const tesla369 = functions.storage

.bucket(bucketName)
.object()
.onChange( async event => {
        const object = event.data;
        const filePath = object.name;
        const imageUri = `gs://${bucketName}/${filePath}`;
        const docId = filePath.split('.jpg')[0];
        const docRef  = admin.firestore().collection('photos').doc(docId);
        // Text Extraction
        const textRequest = await visionClient.documentTextDetection(imageUri)
        const fullText = textRequest[0].textAnnotations[0]
        const text =  fullText ? fullText.description : null
        // Web Detection
        const webRequest = await visionClient.webDetection(imageUri)
        const web = webRequest[0].webDetection
        // Faces
        const facesRequest = await visionClient.faceDetection(imageUri)
        const faces = facesRequest[0].faceAnnotations
        // Landmarks
        const landmarksRequest = await visionClient.landmarkDetection(imageUri)
        const landmarks = landmarksRequest[0].landmarkAnnotations

        // Save to Firestore
        const data = { text, web, faces, landmarks }
        return docRef.set(data)

});

 const imageUri = `gs://${bucketName}/'imagens'/${filePath}`;



I've tried it in every possible way, but it only works when I send the image to the root, if I send into the images folder, the function of this error:

tesla369

 Error: Argument "documentPath" must point to a document, but was "imagens/pagina1". Your path does not contain an even number of components.

0 个答案:

没有答案