1

EXIF データを含む画像をサーバーにアップロードしようとしています。これが私のコードです:

File file = new File(filePath);

FileInputStream fis = new FileInputStream(file);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] b = new byte[1024];

int bytesRead;
while ((bytesRead = fis.read(b)) != -1) {
    bos.write(b, 0, bytesRead);
}
byte[] bytes = bos.toByteArray();

MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
ByteArrayBody bin = new ByteArrayBody(bytes, "image.jpg");
reqEntity.addPart("file", bin);
postMethod = new HttpPost(url);
postMethod.setEntity(reqEntity);
HttpResponse reply = httpClient.execute(postMethod);

最初に、ファイルから直接 FileBody を作成しましたが、EXIF データも保持されませんでした。filePath は、ユーザーが撮影したフル サイズの画像を保存するために Camera アクティビティに指定したパスです。

私の質問は、EXIF 情報を失わずに画像をアップロードするにはどうすればよいですか?

4

0 に答える 0