vxb8874
vxb8874

Reputation: 101

How to populate parse.com table via uploading csv/json file using javascript

I need to upload cvs/json file directly to parse table to populate data (bulk insert) from client side website

As per parse documentation, it seems below curl command can upload a file but it's not clear how to point to a specific parse table.

Is there an equivalent code snippet to call below curl command from java script as i need to make this call from client side website to accept cvs/json file as input and load data

curl -X POST \
  -H "X-Parse-Application-Id: X4ja65SBrNUK88zGBAQgIuR9FWdnvk1QZssZehzu" \
  -H "X-Parse-REST-API-Key: EQVLrkxQRsbiLubm6pY3VVLZkm9a4V0n63cPWrqA" \
  -H "Content-Type: text/plain" \
  -d 'Hello, World!' \
  https://api.parse.com/1/files/hello.txt

Upvotes: 1

Views: 4086

Answers (1)

rickerbh
rickerbh

Reputation: 9913

That REST call will upload a file for storage in Parse. It won't let you import it into the database.

Because you want to run this programmatically from another website, you'll have to use the REST APIs. You'll need to run through each object you want to insert, and make a REST API call to insert it in the database. You can save API hits by batching them together, in blocks of up to 50.

There is also a manual solution, which might be simpler if it's a once-off setup of some initial data. You can do this by opening you web browser, log into your Parse.com account, choose the app you want to import data for, click on Core in the header, and then in the Data section on the left, you'll see an "Import" button. You can upload your CSV or JSON file there. NOTE: this is only valid for importing data into a new class - you can't add data to an existing class (bar the User and Installation I think). If you have an empty class, just delete it and use the file import to create it.

Parse do have some documentation on importing data, available at their website.

Upvotes: 2

Related Questions