android - Add photo to new ParseUser -
i'm using parse android. want add photo newly created parseuser
. here sample code:
if(company.getbackgroundimage()!=null) { bitmap bitmap = bitmapfactory.decoderesource(c.getresources(),r.drawable.launcher); // convert byte bytearrayoutputstream stream = new bytearrayoutputstream(); // compress image lower quality scale 1 - 100 bitmap.compress(bitmap.compressformat.png, 100, stream); byte[] image = stream.tobytearray(); // create parsefile final parsefile file = new parsefile("androidbegin.png", image); user.put("alfa1",file); } user.signupinbackground(new signupcallback(){ @override public void done(parseexception arg0) { if (arg0 == null) { log.i("log_output", "data saved in sever"); } else { log.e("log_output", arg0.getcode() + "data not saved in server"); } } });
the file isn't uploaded!
it isn't uploaded , error code -1; i'm doing signup phase, don't understand how create new user photo. i've converted file, in fact myimage byte[]
, works simple parseobject
. thanks
i not believe signup adds data.
what happens if do:
user.signupinbackground(new signupcallback(){ @override public void done(parseexception arg0) { if (arg0 == null) { user.put("alfa1",file); user.saveinbackground(new savecallback(parseexception e) { if (e != null) { log.e("log_output", "error saving user", e); return; } log.i("log_output", "data saved in sever"); }); } else { log.e("log_output", "error signing user", e); } }
if user logged in @ point in code, should omit signupinbackground.
Comments
Post a Comment