I have error after migration to Parse Server with image upload: "Invalid file upload".
Use android-parse 1.13.1 and parse-server 2.3.2.
Adding Content-Type "image/png" to new ParseFile do not solve problem.
Code:
private ParseFile getParseFile(Bitmap file, String filename) {
// Convert it to byte
ByteArrayOutputStream stream = new ByteArrayOutputStream();
// Compress image to lower quality scale 1 - 100
file.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] image = stream.toByteArray();
return new ParseFile(filename, image, "image/png");
}
ParseFile squarePhotoFile = getParseFile(squarePhoto, "square_photo.png");
squarePhoto.recycle();
squarePhotoFile.saveInBackground(new SaveInBackgroundSquarePhotoCallback(squarePhotoFile));
Please help!
Solved, part of my code was bad:
ParseFile squarePhotoFile = new ParseFile("empty", new byte[]{});
squarePhotoFile.saveInBackground(new SaveInBackgroundSquarePhotoCallback(squarePhotoFile));
After not sending empty byte array to server, problem was solved.