I need to send a binary response (image) using Google Cloud Functions.
My attempted solution is:
// .ts
import {Request, Response} from "express";
export function sendGif(req: Request, res: Response) {
res.contentType("image/gif");
res.send(new Buffer("[Base64 encoded image data goes here]", "base64"));
}
However, the response from this function looks like this:
{"type":"Buffer","data":[71,73,...]} // not binary, but JSON
This code works well with Express, but it doesn't function properly with Cloud Functions. Is this a bug, or is there a different approach I should take?