我正在尝试从我的 firebase 函数中的谷歌云存储桶中读取图像,并使用如下的尖锐库提取其中的一部分
const bucket = admin.storage().bucket('XXX.appspot.com')
const filePath = '1558520481853'
const pipeline = sharp().extract({ left: 0, top: 0, width: 30, height: 30 }).toBuffer().then(
(data:any) =>
console.log("data is::::" + data)
);
bucket.file(filePath).createReadStream().pipe(pipeline);
这失败并出现错误
TypeError: dest.on is not a function
at DestroyableTransform.Readable.pipe (/srv/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:590:8)
at Object.<anonymous> (/srv/lib/index.js:49:46)
at Generator.next (<anonymous>)
at /srv/lib/index.js:7:71
at new Promise (<anonymous>)
at __awaiter (/srv/lib/index.js:3:12)
at exports.extract_text_from_bounding_box.functions.https.onRequest (/srv/lib/index.js:39:82)
at cloudFunction (/srv/node_modules/firebase-functions/lib/providers/https.js:49:9)
at /worker/worker.js:783:7
at /worker/worker.js:766:11
at _combinedTickCallback (internal/process/next_tick.js:132:7)
at process._tickDomainCallback (internal/process/next_tick.js:219:9)
我正在关注示例https://github.com/firebase/functions-samples/blob/master/image-sharp/functions/index.js,它正在写回我不需要的存储桶,只需要提取图像的base64