檔案上傳下載下傳
檢視了系統的配置檔案沒有看到檔案大小限制,
同僚說,可能是客戶這裡伺服器網絡波動導緻網絡連接配接斷開,我覺得有點道理。
java.lang.OutOfMemoryError Java heap space
byte[] bytes;
BufferedOutputStream stream = new BufferedOutputStream(
stream.flush();
logger.info("Server File Location="
return getRelativePathFromUploadDir(serverFile).replaceAll("\\\\", "/");
e.printStackTrace();
}
乍一看沒什麼大問題,我在 stream.write(bytes); 這句加了斷點,發覺根本就沒走到。
既然這樣,把檔案一點點的讀進來即可。
public static String uploadSingleFile(String path,MultipartFile file) {
//bytes = file.getBytes();
File serverFile = createServerFile(path,file.getOriginalFilename());
int length=0;
while ((length = inputStream.read(buffer)) != -1) {
//stream.write(bytes);
// TODO Auto-generated catch block
}