【发布时间】:2019-08-14 14:31:24
【问题描述】:
我有这个流缓冲数据的函数:
function doChunkInput() {
console.log('Put Objects Chunk');
let stream = new Readable({
read() {}
})
for(i=0; i < 1000; i++) {
stream.push(' data');
stream.push(' more data');
stream.push(' and more data');
}
// Pay attention to this
// null indicates the end of the stream, so the `data` event will be fired
stream.push(null)
const params = {
Bucket: bucket,
Body: stream,
Key: `sitemap.1.xml`,
};
return s3.upload(params).promise();
是否可以在没有缓冲的情况下从流中提取。我想要的是流式传输无法计算内容长度的数据。在上面的例子中,它是在缓冲区中计算出来的。
我正在尝试测试分块上传,但在上面的示例中,content-length 标头已添加到请求中,而 transfer-encoding 标头未添加。
【问题讨论】:
标签: javascript node.js stream streaming aws-sdk-js