Currently, I download the image from my cloud storage bucket, encode it in base64 and then pass it in data uri in the src
attribute of an img
tag.
Is there any other way to do this ?
router.post('/images', function(req, res, next) {
var image = bucket.file(req.body.image);
image.download(function(err, contents) {
if (err) {
console.log(err);
} else {
var resultImage = base64_encode(contents);
var index = req.body.index;
var returnObject = {
image: resultImage,
index: index
}
res.send(returnObject);
}
});
});
Is the image publicly readable? If so you can just use
<img src="http://<bucket>.storage.googleapis.com/<object>">
Otherwise you will need to generate a signed URL for a GET operation, which can be used in an image tag.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments