I want to upload an image to an azure function and there persist it to azure blob storage but I cannot find any good articles about how to do this.
SOme posts say it is not possible to do this as node azure functions have problems with multipart.
I don't want my client app to know what storage mechanism is used so I don't want to use azure-storage-node
client library because we will be locked into using.
I've tried this code:
const upload = multer({ storage: multer.memoryStorage() });
module.exports = function(context: Context, req: any) {
upload.any()(req, {} as any, function(err: any) {
context.log('here we are');
if (err) {
throw err;
}
context.log(req.body);
context.log(req);
console.log(req.file);
context.log(req.files);
context.done(undefined, context);
});
But req.files is undefined and I had to set the content type to application/octet-stream
or else I got req.pipe is not a function
.
How can I get the req.files
into azure storage from an azure function?