I checked the past posts about the same issue (saveinbackground-doesnt-work).
I am trying to get the following code working with Parse.com:
sendMessage.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
setProgressBarIndeterminateVisibility(false);
Log.d("Error","Completed Done");
if (e==null){
Toast.makeText(RecipientsActivity.this,"Message Sent!",Toast.LENGTH_LONG).show();
} else {
Log.d("TAG",e.getMessage());
Log.d("TAG",e.getCode() + "error code");
}
}
});
}
This saveinBackground method is taking too long to execute and when it does, it ends with giving the following error: i/o failure: java.net.SocketTimeoutException: null 100error code
I am using Parse in other pieces of the application too wherein I am fetching user contact from the Parse Core.
The message is the new class which is used to post pictures & video's on parse.com I am using the following code to create the ParseObject:
protected ParseObject createMessage(){
ParseObject message = new ParseObject(ParseConstants.CLASS_MESSAGES);
message.put(ParseConstants.KEY_SENDER_ID,ParseUser.getCurrentUser().getObjectId());
message.put(ParseConstants.KEY_SENDER_NAME,ParseUser.getCurrentUser().getUsername());
message.put(ParseConstants.KEY_RECIPIENTS_ID,getRecipientsIDs());
message.put(ParseConstants.KEY_FILE_TYPE,fileType);
//Log.d("TAG1","Message: " + message);
//Log.d("TAG1",mediaUri + "");
byte[] fileBytes = FileHelper.getByteArrayFromFile(this,mediaUri);
if (fileBytes==null) return null;
else {
if (fileType.equals(ParseConstants.FILE_TYPE_IMAGE)){
fileBytes = FileHelper.reduceImageForUpload(fileBytes);
}
String fileName = FileHelper.getFileName(this,mediaUri,fileType);
ParseFile parseFile = new ParseFile(fileName,fileBytes);
message.put(ParseConstants.KEY_FILE,parseFile);
// Log.d("TAG2","Message: " + fileType);
// Log.d("TAG2",mediaUri + "");
return message;
}
}
I checked the logs and found that the message is getting correctly created. Moreover I checked on Parse.com to see if any message class has been created there but none is being shown.
The error i am getting is this :
10-25 19:23:08.695 11405-11405 W/System.err﹕ com.parse.ParseException: Upload to S3 failed. Bad Request
10-25 19:23:08.695 11405-11405 W/System.err﹕ at com.parse.ParseAWSRequest.onResponse(ParseAWSRequest.java:94)
10-25 19:23:08.695 11405-11405/ W/System.err﹕ at com.parse.ParseAWSRequest.onResponse(ParseAWSRequest.java:28)
10-25 19:23:08.695 11405-11405/ W/System.err﹕ at com.parse.ParseRequest$3.call(ParseRequest.java:267)
10-25 19:23:08.695 11405-11405/ W/System.err﹕ at com.parse.Task$3.run(Task.java:199)
10-25 19:23:08.695 11405-11405/ W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
10-25 19:23:08.695 11405-11405/ W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
10-25 19:23:08.695 11405-11405/ W/System.err﹕ at java.lang.Thread.run(Thread.java:841)
After trying to debug the error, I found that if I remove the code to attach the image, it works fine. So i tried various methods to convert image to Byte[] including image uri to byte array and saving files to parse but still i m not finding any luck