Node.js 如何将映像下载到本地存储?

Node.js 如何将映像下载到本地存储?,node.js,google-cloud-functions,firebase-storage,fs,google-cloud-vision,Node.js,Google Cloud Functions,Firebase Storage,Fs,Google Cloud Vision,我正在使用Node.js Firebase Cloud函数,但需要获取存储在Firebase存储中的图像,以便发送到Google Cloud vision API 从本地映像文件发送: // const fileName = 'Local image file, e.g. /path/to/image.png'; // Performs safe search detection on the local file const [result] = await client.safeSearch

我正在使用Node.js Firebase Cloud函数,但需要获取存储在Firebase存储中的图像,以便发送到Google Cloud vision API

从本地映像文件发送:

// const fileName = 'Local image file, e.g. /path/to/image.png';
// Performs safe search detection on the local file
const [result] = await client.safeSearchDetection(fileName);
const detections = result.safeSearchAnnotation;
如何将远程映像下载到本地存储

例如,我希望将此映像存储在本地存储器中:

  const image = await axios.get(imgUrl)
  

为什么不保存到文件系统,记住名称以便以后获取。比如:

const image = await axios.get(imgUrl);
const path = '/home/some/path/somefilename.jpg'
fs.writeFile(path, image, function(err, data) {
    if (err) {
        throw (err);
    }
    // save filepath to wherever for later.
    
});

为什么不发送一个远程映像路径呢@感谢您的回复!!我是这样做的,它的工作之前(5个月)。但今天的API是抛出错误:
TypeError:当我调用
const data=wait client.safeSearchDetection(remoteUrl)时,无法读取null的属性“成人”;const safeSearch=数据[0]。safeSearchAnnotation;safeSearch.成人…
。所以我想可能是因为我使用了remoteUrl。但也许云视觉API已经关闭了?@DougStevenson谢谢你的帮助@你知道怎么解决吗?