【发布时间】:2021-10-08 00:53:22
【问题描述】:
我需要在 nodejs 中编写一个 azure 函数,用于压缩上传到 azure blob 存储中的任何文件。 我有这段代码可以完成这项工作
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
nodejs函数的定义是这样的
module.exports = async function (context, myBlob) {
其中 myBlob 包含文件的内容。
现在压缩使用流
如何将文件内容转换为流并将转换后的文件保存为上述脚本中的输出变量作为 blob 存储中的新文件但在另一个容器中?
谢谢
【问题讨论】:
标签: azure-functions azure-blob-trigger