【发布时间】:2019-04-18 20:19:36
【问题描述】:
有什么方法可以存储 json 对象而不将其转换为流?我可以将其转换为流后上传。但是有没有将对象存储为 {something}.json 而不将其转换为流的方法?
我现在在做什么
const azureStorage = require('azure-storage');
const blobService = azureStorage.createBlobService(accountName, accountKey);
var Readable = require('stream').Readable
var msg = {
a: "something",
b: "anotherthing"
}
var stream = new Readable
stream.push(JSON.stringify(msg))
stream.push(null)
var option = {
contentSettings: {contentType: 'application/json'}
}
stream.pipe(blobService.createWriteStreamToBlockBlob('container', 'something.json', option, function onResponse(error, result) {
console.log("done")
}));
有没有更好的办法?
【问题讨论】:
标签: node.js azure azure-storage azure-blob-storage