Google Cloud Vision - 如果我只有 url,如何从我的存储桶中传递图像?
Google Cloud Vision - How to pass image from my storage bucket if I only have its url?
我是 运行 一个云函数,每次在我的 firestore 上创建特定文档时都会触发它。该文档有一个 public uri 作为字段,它指的是以前存储在我的 GCStorage 存储桶中的图像。
查看 Node.js 示例 here,我可以看到我们必须向 GCVision 客户端提供文件名才能使用 API:
// Performs safe search detection on the local file
const [result] = await GCV.safeSearchDetection(fileName);
const detections = result.safeSearchAnnotation;
console.log("Safe search:");
console.log(`Adult: ${detections.adult}`);
console.log(`Medical: ${detections.medical}`);
console.log(`Spoof: ${detections.spoof}`);
console.log(`Violence: ${detections.violence}`);
console.log(`Racy: ${detections.racy}`);
但是,如果我只有签名的 url 怎么办?
const fileUrl = "https://storage.googleapis.com/my-project-191sa.appspot.com/images/imageName.jpg?GoogleAccessId=firebase-adminsdk-as2af%my-project-191sa.iam.gserviceaccount.com&Expires=4202444800&Signature=AXh..."
我是否必须解析 url 并让 imageName 与 API 一起使用?或者有没有其他方法可以直接提供签名的[=27=]?
好吧,愚蠢的问题。如果您直接传递 uri,它会起作用。
const [result] = await GCV.safeSearchDetection(imageUri);
我是 运行 一个云函数,每次在我的 firestore 上创建特定文档时都会触发它。该文档有一个 public uri 作为字段,它指的是以前存储在我的 GCStorage 存储桶中的图像。
查看 Node.js 示例 here,我可以看到我们必须向 GCVision 客户端提供文件名才能使用 API:
// Performs safe search detection on the local file
const [result] = await GCV.safeSearchDetection(fileName);
const detections = result.safeSearchAnnotation;
console.log("Safe search:");
console.log(`Adult: ${detections.adult}`);
console.log(`Medical: ${detections.medical}`);
console.log(`Spoof: ${detections.spoof}`);
console.log(`Violence: ${detections.violence}`);
console.log(`Racy: ${detections.racy}`);
但是,如果我只有签名的 url 怎么办?
const fileUrl = "https://storage.googleapis.com/my-project-191sa.appspot.com/images/imageName.jpg?GoogleAccessId=firebase-adminsdk-as2af%my-project-191sa.iam.gserviceaccount.com&Expires=4202444800&Signature=AXh..."
我是否必须解析 url 并让 imageName 与 API 一起使用?或者有没有其他方法可以直接提供签名的[=27=]?
好吧,愚蠢的问题。如果您直接传递 uri,它会起作用。
const [result] = await GCV.safeSearchDetection(imageUri);