parse.com - Parse File is Blank when retrieved with Rest Client -
i've tried create parse file using cloud code 2 ways. first way using byte api added other creating byte array. using byte array method able access file generated , desired file using url returned parse file in sample code. when used parse rest client returned blank file.
file returned file generation :http://files.parsetfss.com/02247568-8b6c-4f69-b50c-a3daefb84755/tfss-07089997-8a39-436d-82e0-71b36eeed42c-userid4_car.csv
file returned rest client using master key on: http://files.parsetfss.com/02247568-8b6c-4f69-b50c-a3daefb84755/tfss-9f4f17da-9e8b-4d40-9e26-31ee915fa51e-userid4_car.csv
file returned rest client using master key off: http://files.parsetfss.com/02247568-8b6c-4f69-b50c-a3daefb84755/tfss-c448fa26-fbef-4195-ae16-a66217d94a45-userid4_car.csv
file returned using curl: http://files.parsetfss.com/02247568-8b6c-4f69-b50c-a3daefb84755/tfss-6c743684-c081-478c-8fdd-df64bfa6d855-userid4_car.csv
var buffer = require('buffer').buffer; function stringtobytes(str) { var bytes = []; (var = 0; < str.length; ++i) { bytes.push("0x"+bytetohex(str.charcodeat(i))); } return bytes; } function bytetohex(b) { var hexchar = ["0", "1", "2", "3", "4", "5", "6", "7","8", "9", "a", "b", "c", "d", "e", "f"]; return hexchar[(b >> 4) & 0x0f] + hexchar[b & 0x0f]; } parse.cloud.define("exportdata", function (request, response) { var jsonstring =[{"vehicle":"bmw","date":"30, jul 2013 09:24 am","location":"hauz khas, enclave, new delhi, delhi, india","speed":42},{"vehicle":"honda cbr","date":"30, jul 2013 12:00 am","location":"military road, west bengal 734013, india","speed":0},{"vehicle":"supra","date":"30, jul 2013 07:53 am","location":"sec-45, st. angel's school, gurgaon, haryana, india","speed":58},{"vehicle":"land cruiser","date":"30, jul 2013 09:35 am","location":"dlf phase i, marble market, gurgaon, haryana, india","speed":83},{"vehicle":"suzuki swift","date":"30, jul 2013 12:02 am","location":"behind central bank ro, ram krishna rd by-lane, siliguri, west bengal, india","speed":0},{"vehicle":"honda civic","date":"30, jul 2013 12:00 am","location":"behind central bank ro, ram krishna rd by-lane, siliguri, west bengal, india","speed":0},{"vehicle":"honda accord","date":"30, jul 2013 11:05 am","location":"dlf phase iv, super mart 1, gurgaon, haryana, india","speed":71}]; var csvstring = jsontocsvconvertor(jsonstring, "export", true); var dataforfile = new buffer(csvstring).tostring('base64'); var dataforfile2 = stringtobytes(csvstring); var parsefile = new parse.file("userid4_car.csv", dataforfile2); parsefile.save().then(function() { response.success(parsefile); }, function(error) { response.error(error); }); });
Comments
Post a Comment