http - Change URLs into files (Parse.com using Javascript CloudCode) -


i need batch change number of image links (url's links exist within class in) image files (that parse.com hosts).

cloud code (apparently) how it.

i've followed documentation here haven't had success.

what wanted is:

  1. take url link "column_1"
  2. make file
  3. upload file "column_1" (overwrite existing url). if dangerous- can upload new column ("column_2").
  4. repeat next row

this code did not work (this first time js):

imgfile.save().then(function () {     object.set("column_1", imgfile);     return object.save(); }).then(function (classname) {     response.success("saved object"); }, function (error) {    response.error("failed save object"); }); 

can recommend how this?

ok- works else trying.

    parse.cloud.job("convertfiles", function(request, status) { //cuts rundata out of poor runs     function sleep(milliseconds) {       var start = new date().gettime();       (var = 0; < 1e7; i++) {         if ((new date().gettime() - start) > milliseconds){           break;         }       }     }      // tell js cloud code keep log of it's upto. manually create 1 row (in class "debugclass") object id     parse.cloud.usemasterkey();      var debug = parse.object.extend("debugclass");     var queryfordebugobj = new parse.query(debug);     queryfordebugobj.equalto("objectid", "kbwwdv2s57");      // query users     // var queryforsublist = new parse.query(parse.object.extend("gentest"));       queryfordebugobj.find({         success: function(results) {             var debugobj = results[0];              var processcallback = function(res) {                     var entry = res[0];                     var debugobj = results[0];                     debugobj.set("lastobject", entry.id);                     debugobj.save();                      parse.cloud.httprequest({                         url: entry.get("smallimage2"),                         method: "get",                         success: function(httpimgfile)                          {                             console.log("httpimgfile: " + string(httpimgfile.buffer));                             var imgfile = new parse.file("picture.jpg", {base64: httpimgfile.buffer.tostring('base64')});                              imgfile.save().then(function () {                                 console.log("2");                                 entry.set("smallimage1", imgfile);                                 entry.save(null, {                                   success: function(unused) {                                     debugobj.increment("itemdone");                                     sleep(20);                                     res.shift();                                     if (res.length === 0) {                                         process(entry.id);                                         return;                                     }                                     else {                                         processcallback(res);                                     }                                     },                                   error: function(unused, error) {                                     response.error("failed save entry");                                   }                                 });                                 });                                                                      },                         error: function(httpresponse)                          {                             console.log("unsuccessful http request");                             response.error(responsestring);                         }                     });             };             var process = function(skip) {{                 var queryforsublist = new parse.query("genpants");                  if (skip) {                     queryforsublist.greaterthan("objectid", skip);                     console.error("last object retrieved:" + skip);                 }                 queryforsublist.ascending("objectid");                 queryforsublist.find().then(function querysuccess(res) {                     processcallback(res);                 }, function queryfailed(reason) {                     status.error("query unsuccessful, length of result " + result.length + ", error:" + error.code + " " + error.message);                 });             }};              process(debugobj.get("lastobject"));          },         error: function(error) {             status.error("xxx uh oh, went wrong 2:" + error + "  " + error.message);         }     });   }); 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -