Skip to content

Commit

Permalink
更新文件上传位置
Browse files Browse the repository at this point in the history
  • Loading branch information
huoji555 committed Jun 19, 2018
1 parent 35da39d commit 300b877
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 25 deletions.
13 changes: 2 additions & 11 deletions src/main/java/com/hwj/web/FileController.java
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ public String uploadallfile(
}

String ip = InetAddress.getLocalHost().getHostAddress();
System.out.println("ip" + ip);

// 看文件大小
byte[] newsPageByte = file.getBytes();
Expand Down Expand Up @@ -333,20 +332,12 @@ public String uploadallfile(
String URL = string[1];
// 文件的真实路径,将之代替截图路径存入
String url = URL.replaceAll("\\\\", "/") + "." + fileExtension;
String real = realPath.replaceAll("\\\\", "/");

System.out.println("-------------------");
System.out.println(url);
System.out.println(real);
System.out.println("-------------------");

Url3 = url; // 文件在服务器中的真实路径,用来删除
Url2 = "http://" + ip + ":8080/"+ url.split("C:/")[1]; //代表服务器中的地址

//Url2 = "http://" + ip + ":8080/"+ url.split("C:/")[1]; //代表服务器中的地址
Url2 = "/"+ url.split("C:/")[1];
}

ByteArrayInputStream bis = new ByteArrayInputStream(newsPageByte);

Blob blob = streamToBlob.toBlob(file.getInputStream());

FileStream fileStream = new FileStream();
Expand Down
9 changes: 2 additions & 7 deletions src/main/java/com/hwj/web/FileStreamController.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,13 @@ public String writreFileStream(@RequestBody String requestJsonBody,
byte[] QN = streamToBlob.blobToBytes(blob);
String fileExtension = fileStream.getFileExtension();

String realPath = request.getSession().getServletContext()
.getRealPath("/");
String fileURL = realPath + "upload";
String fileURL = "C:\\upload";

BeSaveFileUitl be = new BeSaveFileUitl();
be.setFileExtension(fileExtension);
be.setFilesByte(QN);
be.setFileURL(fileURL);

String ip = InetAddress.getLocalHost().getHostAddress();


String Url2 = "";
String Url3 = "";
Expand All @@ -155,10 +151,9 @@ public String writreFileStream(@RequestBody String requestJsonBody,
String URL = string[1];
// 文件的真实路径,将之代替截图路径存入
String url = URL.replaceAll("\\\\", "/") + "." + fileExtension;
String real = realPath.replaceAll("\\\\", "/");

Url3 = url; // 文件在服务器中的真实路径,用来删除
Url2 = "http://" + ip + ":8080/"+ url.split(real)[1]; //代表服务器中的地址
Url2 = "/"+ url.split("C:/")[1]; //代表服务器中的地址

}

Expand Down
9 changes: 2 additions & 7 deletions src/main/java/com/hwj/web/NewMindController.java
Original file line number Diff line number Diff line change
Expand Up @@ -1311,18 +1311,14 @@ public String setMapUpload(@RequestParam("nodeid") String nodeid,
type = "other";
}
byte[] newsPageByte = file.getBytes();
String realPath = request.getSession().getServletContext()
.getRealPath("/");

String fileURL = realPath + "upload";
String fileURL = "C:\\upload";

BeSaveFileUitl be = new BeSaveFileUitl();
be.setFileExtension(fileExtension);
be.setFilesByte(newsPageByte);
be.setFileURL(fileURL);

String ip = InetAddress.getLocalHost().getHostAddress();
System.out.println("ip" + ip);

String Url2 = "";
String Url3 = "";
Expand All @@ -1333,10 +1329,9 @@ public String setMapUpload(@RequestParam("nodeid") String nodeid,
String URL = string[1];
// 文件的真实路径,将之代替截图路径存入
String url = URL.replaceAll("\\\\", "/") + "." + fileExtension;
String real = realPath.replaceAll("\\\\", "/");

Url3 = url; // 文件在服务器中的真实路径,用来删除
Url2 = "http://" + ip + ":8080/"+ url.split(real)[1]; //代表服务器中的地址
Url2 = "/"+ url.split("C:/")[1]; //代表服务器中的地址

}

Expand Down

0 comments on commit 300b877

Please sign in to comment.