如何从Google Cloud功能将图像文件上传到Google Storage Bucket

编程入门 行业动态 更新时间:2024-10-10 04:28:33

如何从Google Cloud功能将图像<a href=https://www.elefans.com/category/jswz/34/1770535.html style=文件上传到Google Storage Bucket"/>

如何从Google Cloud功能将图像文件上传到Google Storage Bucket

我有一个Google Cloud功能,该功能可以获取网址的屏幕截图,并且我需要将该图像从Google Cloud功能上传到Google Cloud Bucket中]

我尝试使用下面给出的代码上传它,但是它不起作用并给出错误信息

    /**
     * Responds to any HTTP request.
     *
     * @param {!express:Request} req HTTP request context.
     * @param {!express:Response} res HTTP response context.
     */
    exports.takeScreenshot = (req, res) => {

    const Screenshot = require('url-to-screenshot')
    const Storage = require('@google-cloud/storage')
    const fs = require('fs')
    const bucketName="screenshot_bucket_mujahid"
    new Screenshot('/')
      .width(800)
      .height(600)
      .capture()
      .then(img =>
        Storage
        .bucket(bucketName)
        .upload(img,"mujahid.jpg"))
        console.log('open example.png')
      })

      let message = req.query.message || req.body.message || 'Hello World!';
      res.status(200).send(message);
       };

我有一个Google Cloud功能,该功能可获取url的屏幕快照,我需要将该图像从google cloud功能上传到google cloud bucket,我曾尝试使用下面给出的代码上传该图像...

回答如下:您的代码似乎有语法错误。代替:

更多推荐

如何从Google Cloud功能将图像文件上传到Google Storage Bucket

本文发布于:2024-05-06 19:26:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1753721.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件上传   图像   功能   Cloud   Google

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!