Hello,
j'essaye d'envoyer des images via une requête POST multipart mais j'ai un problème de compression juste sur certaines images ou il me fait un NullPointerException. Les photos sont pourtant prisent par le même téléphone.
Voici le code qui pose problème :
A la première image aucun problème mais à la seconde j'ai une exception.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 protected static void getImageEntity(String filePath, String name) throws IOException { if (filePath.equals("")) { bos = new ByteArrayOutputStream(); image = BitmapFactory.decodeFile(filePath); image.compress(CompressFormat.JPEG, 90, bos); byte[] data = bos.toByteArray(); ByteArrayBody bab = new ByteArrayBody(data, filePath); reqEntity.addPart(name, bab); image.recycle(); bos.close(); } }
Quelqu'un aurai une idée ? sivouplai![]()
Partager