当我从打字稿中的文件路径读取文件时。我收到以下错误:-对象没有成员'statSync',而对象没有成员'createReadStream'。
Below is the code:=
const fs = require('fs');
let filePath:='D:\\Dummy.pdf';
let streamingInput;
if (filePath) {
streamingInput = {
contentLength: fs.statSync(filePath).size,
contentType: contentType,
stream: fs.createReadStream(filePath)
};
return streamingInput;
}
答案 0 :(得分:0)
k6不是基于nodejs的,因为不支持此类nodejs标准库,您可能已经使用过browserify(如您所愿)使其在k6中工作。 但是浏览器显然是doesn't support statSync或createReadStream。
我建议您只使用k6的open(),它不会流式传输内容,而是会在内存中读取它们。
为大文件添加流阅读器可能是个好主意,尤其是考虑到当前文件内容将为k6运行完全独立的JS VM的每个VU提供一个副本。如果您能open an issue对此感到高兴