我有这个json:
var myJSON = '{"kind": "person", "fullName": "Rivka3"}';
我正在尝试使用createReadStream将其上传到bigquery。 当我将其保存在本地时,我成功了:
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);
});
});
我现在正在尝试不通过本地保存来完成这个操作 - 使用缓冲区:
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