Commit 0e17af31 authored by 王琮's avatar 王琮

打包

parent 1aede14e
......@@ -147,9 +147,9 @@ public class FileCtrl {
fileName = file.getFileName();
String originPath = "";
if (fileNum.startsWith("http")) {
originPath = fileNum;
originPath = fileName;
} else {
originPath = this.getfileUrl() + fileNum;
originPath = this.getfileUrl() + fileName;
}
String targetPath = myPath + fileName;
......@@ -197,7 +197,7 @@ public class FileCtrl {
outputStream.write(data);
outputStream.flush();
outputStream.close();
zipFileDownLoad.delete();
//zipFileDownLoad.delete();
} else {
System.out.println("下载的文件不存在");
}
......@@ -220,7 +220,7 @@ public class FileCtrl {
map.put("fileName", myfile.getOriginalFilename());
map.put("fileID", uuid);
byte[] buffer = myfile.getBytes();
FileOutputStream fos = new FileOutputStream(this.getfileUrl() + fileNum);
FileOutputStream fos = new FileOutputStream(this.getfileUrl() + myfile.getOriginalFilename());
fos.write(buffer);
fos.close();
File file = new File();
......
......@@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
......@@ -204,11 +205,11 @@ public class QuestionnaireCtrl {
}
@RequestMapping({"downZipByFileId"})
public String downZipByFileId(Long id, HttpServletRequest request, HttpServletResponse response) throws IOException {
public String downZipByFileId(@RequestParam Long optionId, HttpServletResponse response) throws IOException {
String forwardName = "/user/file";
//1.根据选项查询文件列表
String forderName = UUIDUtils.getUUID();
String tempPath = this.getfileUrl();
String tempPath = this.getFileUrl();
String zipName="上传文件";
String fileName;
String myPath = tempPath + forderName + "/" + zipName + "/";
......@@ -216,7 +217,7 @@ public class QuestionnaireCtrl {
if (!fileForExists.exists()) {
FileUtil.mkdirFolders(myPath);
}
List<String> fileID = this.fileServer.selectFileId(id);
List<String> fileID = this.fileServer.selectFileId(optionId);
for(int i=0;i<fileID.size();++i) {
File file = this.fileServer.selectFileByFileID(fileID.get(i));
try {
......@@ -225,9 +226,9 @@ public class QuestionnaireCtrl {
fileName = file.getFileName();
String originPath = "";
if (fileNum.startsWith("http")) {
originPath = fileNum;
originPath = fileName;
} else {
originPath = this.getfileUrl() + fileNum;
originPath = this.getFileUrl() + fileName;
}
String targetPath = myPath + fileName;
StringBuffer fileNameForRepeat = new StringBuffer();
......@@ -270,7 +271,7 @@ public class QuestionnaireCtrl {
outputStream.write(data);
outputStream.flush();
outputStream.close();
zipFileDownLoad.delete();
//zipFileDownLoad.delete();
} else {
System.out.println("下载的文件不存在");
}
......@@ -280,7 +281,7 @@ public class QuestionnaireCtrl {
return null;
}
private String getfileUrl() throws IOException {
private String getFileUrl() throws IOException {
if ("".equals(fileUrl)) {
Properties props = new Properties();
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("file.properties");
......
......@@ -156,7 +156,6 @@ public class FileUtil {
public static File copyFileByPath(String originPath, String targetPath, String targetPathForRepeat) throws IOException {
File targetFile = new File(targetPath);
try {
BufferedInputStream input = null;
if (originPath.startsWith("http")) {
......@@ -173,20 +172,16 @@ public class FileUtil {
byte[] buffer = new byte[1048576];
int bytesum = 0;
boolean var8 = false;
int byteread;
while((byteread = input.read(buffer)) != -1) {
bytesum += byteread;
fps.write(buffer, 0, byteread);
fps.flush();
}
fps.close();
input.close();
} catch (Exception var9) {
}
return targetFile;
}
}
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