I want to convert JSON data to CSV and then convert that CSV data to CSV file type and then use that file type object to upload on firebase. I converted JSON to CSV but I am unable to convert that data to CSV file type object to upload on firebase as a file
1 Answer
Convert CSV to 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});
Per the Firebase documentation here, you should be able to use Blob to store it in Firebase.
var file = ... // use the Blob or File API
ref.put(file).then(function(snapshot) {
console.log('Uploaded a blob or file!');
});
2 Comments
Muhammad Abdullah
thanks for helping.I'll update the status after checking the method
sidthesloth
Set let me know.