Commit abd6fffd authored by neo's avatar neo

[DEV] write http inputstrem to tempfile output stream

parent e64f7125
......@@ -12,6 +12,10 @@ import org.springframework.web.multipart.MultipartHttpServletRequest;
import pwc.taxtech.atms.constant.enums.EnumModule;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.util.Calendar;
import java.util.Date;
......@@ -69,6 +73,21 @@ public class FileUploadAdapter {
if (completeFile.exists()) completeFile.delete();
}
try (FileOutputStream fos = new FileOutputStream(new File(tempPath));
InputStream inputStream = request.getFile(FILE_NAME).getInputStream();) {
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = inputStream.read(buffer, 0, buffer.length)) != 0) {
fos.write(buffer, 0, bytesRead);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if (paramBean.isLastChunk) {
LOGGER.debug("Last chunk arrived");
File completeFile = new File(completePath);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment