Reputation: 1205
I am getting error while uploading image on Parse.Please Help me about this. I tried some Stack overflow question but its nothing, So please help me,Thank in advance.
When i press Submit button then i am getting following error.
error is
java.lag.illegalStateException: Unable to encode an unsaved parsefile
and my code is
bitmapLogo=BitmapFactory.decodeFile(picturePath);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmapLogo.compress(Bitmap.CompressFormat.PNG,0, stream);
byte[] image = stream.toByteArray();
String filename=etUser.getText().toString()+".png";
ParseFile file = new ParseFile(filename, image);
System.out.println("PARSE FILE NAME : "+picturePath);
file.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
if(e!=null){
btSignup.setText(e.getMessage());
}
}
},new ProgressCallback() {
@Override
public void done(Integer integer) {
btSignup.setText(""+integer);
}
});
String spin= String.valueOf(spinBCat.getSelectedItem());
ParseUser user = new ParseUser();
user.setUsername(etUser.getText().toString());
user.setPassword(etPass.getText().toString());
user.setEmail(etEmail.getText().toString());
user.put("logoname",etUser.getText().toString());
user.put("blogo",file);
user.signUpInBackground(new SignUpCallback() {
public void done(ParseException e) {
if (e == null) {
Toast.makeText(AddBusinessActivity.this,"You are Successfully Signed Up",Toast.LENGTH_LONG).show();
signUpSucess();
} else {
Toast.makeText(AddBusinessActivity.this,""+e.getMessage(),Toast.LENGTH_LONG).show();
// Sign up didn't succeed. Look at the ParseException
// to figure out what went wrong
}
}
});
Upvotes: 3
Views: 1977
Reputation: 1205
Finally I solve this answer. Just add code in ProgressCallback
method
Code is
bitmapLogo=BitmapFactory.decodeFile(picturePath);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmapLogo.compress(Bitmap.CompressFormat.PNG,0, stream);
byte[] image = stream.toByteArray();
String filename=etUser.getText().toString()+".png";
ParseFile file = new ParseFile(filename, image);
System.out.println("PARSE FILE NAME : "+picturePath);
file.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
if(e!=null){
btSignup.setText(e.getMessage());
}
}
},new ProgressCallback() {
@Override
public void done(Integer integer) {
String spin= String.valueOf(spinBCat.getSelectedItem());
ParseUser user = new ParseUser();
user.setUsername(etUser.getText().toString());
user.setPassword(etPass.getText().toString());
user.setEmail(etEmail.getText().toString());
user.put("logoname",etUser.getText().toString());
user.put("blogo",file);
user.signUpInBackground(new SignUpCallback() {
public void done(ParseException e) {
if (e == null) {
Toast.makeText(AddBusinessActivity.this,"You are Successfully Signed Up",Toast.LENGTH_LONG).show();
signUpSucess();
} else {
Toast.makeText(AddBusinessActivity.this,""+e.getMessage(),Toast.LENGTH_LONG).show();
// Sign up didn't succeed. Look at the ParseException
// to figure out what went wrong
}
}
});
}
});
Upvotes: 1