0

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 1

1

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!');
});
Sign up to request clarification or add additional context in comments.

2 Comments

thanks for helping.I'll update the status after checking the method
Set let me know.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.