I need to create a function to accept an incoming form with a file attachment and upload it to an Azure blob storage container. I have gotten the function to upload to Azure. Initially I was just getting a blank file. But then I used the information in this stackoverflow question to restructure my function. Now I'm getting an object instead of a blank file.
Currently my function looks like this:
async function uploadFile (req, res) {
try {
var formidable = require('formidable');
var fs = require('fs');
const storage = require('@azure/storage-blob')
const { randomBytes } = require('crypto');
const blobNameUniq = Math.random().toString(36).slice(2) + randomBytes(8).toString('hex') + new Date().getTime();
const accountname ="MYACCOUNT_HERE";
const key = "MYKEY_HERE";
const cerds = new storage.StorageSharedKeyCredential(accountname,key);
const blobServiceClient = new storage.BlobServiceClient(`https://${accountname}.blob.core.windows.net`,cerds);
const containerName= blobServiceClient.getContainerClient('dev');
const containerClient = await blobServiceClient.getContainerClient(containerName.containerName);
let form = new formidable.IncomingForm();
form.parse(req, async function (err, fields, files) {
const file = files.file;
const blobName = blobNameUniq + files.file;
const contentType = file.type;
console.log('content type is: ', contentType)
const filePath = file.path;//This is where you get the file path.
console.log('filePath is: ', filePath)
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
const uploadBlobResponse = await blockBlobClient.uploadFile(filePath);
return uploadBlobResponse
});
}
catch (error) {
console.log(error);
}
}
What I see in Azure (as shown in the link below) is [object Object] at the end of the file name and application/octet-stream as the type. (The file I was testing with is a .png.)

It feels like the problem is that I'm not actually sending just the file to Azure. But I haven't been able to work out what I need to change.
For what it's worth, I have a function successfully connecting to my Azure blob storage to return a SAS for existing blobs. So I feel sure my account and account keys are correct. I'm also getting no error messages back from Azure. Via console.log I'm also able to see that the form parses properly and I can see the proper name, path and mime type.
Any suggestions on what I need to change to make this work?