I really enjoyed the ashokguju decision. In my case, I wanted to save the picture from the Android device offline, so this is what happened to me:
1.- Just by doing this (ashokgujju solution), you wonβt add the file to your syntax table, as SAndroidD pointed out, if you want it, you can use the Parse Cloud aftersave function, something like this:
Parse.Cloud.afterSave("Recordings_or_WhatEverYourTableIs", function(request){ bytes = request.object.get("data"); //"data" is the name given by ashokgujju at "obj.put("data", data);" if(bytes){ var file = new Parse.File("myFile.png", bytes); //png or whatever you want file.save().then(function(success){ request.object.set("record_or_MyColumnWithParseFile", file); request.object.unset("data"); //optional, if you are not going to use this data, it has no meaning keep it there anymore and you will save some space request.object.save(); },function(error){ //error }); } }
It worked like a charm! but...
2. But only for the thumbnail, I mean, a very small picture, as soon as I wanted to do the same with the big picture, I came across this:
com.parse.ParseRequest$ParseRequestException: The object is too large -- should be less than 128 kB
It took me a while to figure this out, because there are no errors where shown, just like SAndroidD. I had to add a callback to save it in order to see it.
File file = new File(filePath); FileInputStream fis = null; try { fis = new FileInputStream(file); byte data[] = new byte[(int) file.length()]; fis.read(data); ParseObject obj = new ParseObject("Recordings"); obj.put("name", name); obj.put("data", data); obj.saveEventually(new SaveCallback() { @Override public void done(ParseException e) { Log.i(MyClass.logName," is it everything ok boy? "+e); } }); } catch (IOException e) { e.printStackTrace(); }
So! to summarize: ashokgujju cool workaround plus my afterSave function will keep any parseFile offline while the file itself is not so big.