FileInputStream fis;
String uploadBuffer = "";
try {
fis = new FileInputStream(FILEPATH);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int count = 0;
while ((count = fis.read(buffer)) >= 0) {
baos.write(buffer, 0, count);
}
uploadBuffer = new String(Base64.encode(
baos.toByteArray(), Base64.DEFAULT)); // 进行Base64编码
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
jsonObjectDefectPhoto.put("FILEBUFFER",
uploadBuffer);
图片转为数据流
最新推荐文章于 2021-03-02 06:43:45 发布