我想将 JSON 数据转换为 CSV,然后将该 CSV 数据转换为 CSV 文件类型,然后使用该文件类型对象上传到 firebase。我将 JSON 转换为 CSV,但我无法将该数据转换为 CSV 文件类型对象以作为文件上传到 firebase
1 回答
GCT1015
TA贡献1827条经验 获得超4个赞
将 CSV 转换为 BLOB
var CSV = [
'"1","val1","val2"',
'"2","val1","val2"',
'"3","val1","val2"'
].join('\n');
window.URL = window.webkitURL || window.URL;
var contentType = 'text/csv';
var csvFile = new Blob([CSV], {type: contentType});
根据此处的Firebase 文档,您应该能够使用Blob它来将其存储在 Firebase 中。
var file = ... // use the Blob or File API
ref.put(file).then(function(snapshot) {
console.log('Uploaded a blob or file!');
});
添加回答
举报
0/150
提交
取消
