我正在尝试从 API 流式传输一些数据,对其进行转换,然后使用 Azure 函数上传到 Azure blob。我使用 Azure Blobstore 面临的限制是没有“writeStream”,只有 uploadStream。管道中没有明显的点可以上传到流。
示例-
function MyWriter(writer) {
return new WritableStream({
write(chunk) {
console.log('writing');
writer.write(chunk);
},
});
}
export const generate = async (iterable) => {
await ReadableStream.from(iterable);
.pipeThrough(new TextDecoderStream())
.pipeThrough(new MyTransformer())
.pipeThrough(new CompressionStream('gzip'))
.pipeTo(MyWriter(writeOutStream));
/*. await blockBlobClient.uploadStream(); */
}
我错过了一些明显的东西吗?
Azure 上传流文档 - https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-upload-javascript#upload-a-block-blob-from-a-stream
尝试了各种管道组合,但没有明显的上传流的点。
const readableStream = ReadableStream.from(myIterable);
.pipeThrough(new TextDecoderStream())
.pipeThrough(new MyTransformer())
.pipeThrough(new CompressionStream('gzip'));
await blockBlobClient.uploadStream(Readable.fromWeb(readableStream), readableStream);
'blobbyBlobbyBlobby.xml.gz',
);