public ResponseEntity<byte[]> uploadBigFile(String path) {
HttpHeaders headers = new HttpHeaders();
File apkFile = new File(path);
try {
headers.setContentDispositionFormData("attachment", new String(apkFile.getName().getBytes("UTF-8"), "ISO-8859-1"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
// FileInputStream fis = null;
BufferedInputStream fis=null;
ByteArrayOutputStream outputStream = null;
try {
// fis = new FileInputStream(apkFile);
fis = new BufferedInputStream(new FileInputStream(apkFile));
logger.info("fis:{}", fis);
outputStream = new ByteArrayOutputStream();
byte[] bytes = new byte[1024];
int read = 0;
while ((read = fis.read(bytes)) != -1) {
outputStream.write(bytes, 0, read);
}
// logger.info("outputStream:{}", outputStream);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return new ResponseEntity<byte[]>(outputStream.toByteArray(), headers, HttpStatus.CREATED);
}