文件上传到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
发布评论