8
我有這個JSON來創建一個緩衝區readstream:如何使用的NodeJS
var myJSON = '{"kind": "person", "fullName": "Rivka3"}';
我試圖uploed它的BigQuery,使用createReadStream。 當我保存它localy我成功:
fs.writeFile("/tmp/bq_json_file_new.json", myJSON, function(err){});
fs.createReadStream("/tmp/bq_json_file_new.json")
.pipe(table.createWriteStream(metadata))
.on('complete', function(job) {
job
.on('error', console.log)
.on('complete', function(metadata) {
console.log('job completed', metadata);
});
});
現在我想這樣做沒有localy保存它 - 使用緩衝器:
fs.createReadStream(new Buffer(myJSON, "utf8"))
.pipe(table.createWriteStream(metadata))
.on('complete', function(job) {
job
.on('error', console.log)
.on('complete', function(metadata) {
console.log('job completed', metadata);
});
});
,但我收到此錯誤:
fs.js:575
binding.open(pathModule._makeLong(path),
TypeError: path must be a string