I am attempting to send an image to my google cloud function to store in my google storage bucket. I am using Postman to test my function, but I am getting no where.
This is the code I am using for the cloud function.
const functions = require('@google-cloud/functions-framework');
const { Storage } = require('@google-cloud/storage');
const Busboy = require('busboy');
const storage = new Storage();
functions.http('hello', (req, res) => {
const busboy = Busboy({ headers: req.headers });
busboy.on('file', (fieldname, file, filename, encoding, mimetype) => {
console.log('Received file:', filename);
console.log('File size:', file.length, 'bytes');
console.log('MIME type:', mimetype);
});
busboy.on('error', (err) => {
console.error('Error occurred during file upload:', err);
res.status(500).send(err);
});
busboy.on('finish', () => {
res.send(filename);
res.end();
});
req.pipe(busboy);
});
Node version: 20 Busboy version: 1.6
EDIT: I have confirmed that the req.body is being sent correctly.