i need to write an azure function in nodejs that compress any files uploaded in the azure blob storage. i have this piece of code that does the job
const zlib = require('zlib');
const fs = require('fs');
const def = zlib.createDeflate();
input = fs.createReadStream('file.json')
output = fs.createWriteStream('file-def.json')
input.pipe(def).pipe(output)
the azure function
the definition of the nodejs function is this
module.exports = async function (context, myBlob) {
where myBlob contains the content of the file.
now the compression use the stream
how can I convert the file content into a stream and save the converted file that in the script above is the output variable as a new file in the blob storage but in another container?
thank you