I'm trying to upload an normal jpeg image with the ParseFile.saveInBackground. Parse responds with an link, but the image is broken.
byte[] da = getImage(quelle.substring(quelle.indexOf('[')+1, quelle.indexOf(']')));
System.out.println(String.format("byte: %d, kb: %d, mb: %d", da.length, da.length/1024, (da.length/1024)/1024));
ParseFile file = new ParseFile("pic.jpg", getImage(id));
file.setContentType("image/jpg");
file.save();
file.saveInBackground();
parseObject.put("image", file);
The getImage method generates only the byte[]:
Path path = Paths.get(listOfFiles[j].toURI());
return Files.readAllBytes(path);
After the save request on the file, parse responds with
{"name":"tfss-951560de-3fd3-43b6-ad79-dab7de18f121-pic.jpg",
"url":"http://ift.tt/1GWAiSM"}
But the image is broken. If I make the upload with a curl script, the upload works perfect:
curl -X POST \
-H "X-Parse-Application-Id: iKD77L3n7SVsKM8a6k0d4ry4QLfZS89zEj86F4Pk" \
-H "X-Parse-REST-API-Key: yeyNSjDwWy8w9bo6RJ0Y5NN5tx07FQmQTiR7fHxf" \
-H "Content-Type: image/jpeg" \
--data-binary '@master-05561825 Kopie.jpg' \
http://ift.tt/1aiT89L
Btw. does anyone know what the '@' symbol stands for in the --data-binary?
Do I generate the byte[] wrong?
Aucun commentaire:
Enregistrer un commentaire