Reputation: 1755
parse.com provide a way to save ParseObject in offline mode with object.saveEventually(); call.. this stores object in local dataStore unless the syncing done with server.
The problem is,I can not store Parsefile Like Parse object saveEventully(); method
here is my code:
// Locate the image in res > drawable-hdpi
Bitmap bitmap = Util.convertBitmap(ImgLocalPath);
// Convert it to byte
ByteArrayOutputStream stream = new ByteArrayOutputStream();
// Compress image to lower quality scale 1 - 100
bitmap.compress(Bitmap.CompressFormat.JPEG, 100,
stream);
byte[] image = stream.toByteArray();
// Create the ParseFile
final ParseFile file = new ParseFile("NC_Image",
image);
// Upload the image into Parse Cloud
file.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException arg0) {
final ParseObject ncImagesObj = new ParseObject("NCImages");
ParseObject userObject = ParseObject.createWithoutData("AppUsers", userId);
ncImagesObj.put("user", userObject);
ncImagesObj.put("comment",obj.getComment());
ncImagesObj.put("UserType", UserType);
ncImagesObj.saveEventually(new SaveCallback() {
@Override
public void done(ParseException arg0) {
ncImagesObj.put("image", file);
ncImagesObj.saveInBackground();
System.out
.println("Images Save....");
}
});
}
}, new ProgressCallback() {
@Override
public void done(Integer arg0) {
// TODO Auto-generated method stub
}
});
But this will not work Only 'NC_Image' ParseObject Create ,but it can not put image ParseFile into that object.
Anyone have solution... plz help me to find out the solution
Upvotes: 1
Views: 1123
Reputation: 1755
I was wrong its not possible to store/create Parse File in OFFLINE mode,
because Parse File Generate unique object Id of File after Uploading file byte.
That's why it's not possible, But
To solve this problem, I have to store image locally and when network is on after that create Parse File(upload on server) in background.
Thanks for help.. :)
Upvotes: 2