How to upload file using Parse.Cloud.httpRequest for zip content type
I wanted to create a scheduled Parse job to download a zip file. I tried it with Parse.Cloud.httpRequest () but it looks like it only works for json and url encoded content type.
How can I get this from cloud code?
Parse.Cloud.define("getPage", function(request, response) {
Parse.Cloud.httpRequest({
url: 'http://www.nseindia.com/content/historical/EQUITIES/2015/MAY/cm12MAY2015bhav.csv.zip',
headers: {
"Content-type": "application/zip",
"Expires": "0",
"Content-disposition": 'attachment; filename="cm12MAY2015bhav.csv.zip"',
"User-Agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36"
},
success: function(httpResponse) {
console.log("Response-text:"+ httpResponse.text);
console.log("Response-text:"+ httpResponse.data);
//response(httpResponse.text);
},
error: function(httpResponse) {
console.log("Error hit, error: "+ httpResponse.text);
//response('Request failed with response code ' + httpResponse.status);
}
});
});
The above code produces "Undefined" for httpResponse.data.
+3
source to share