作业导出,删除注释代码

This commit is contained in:
yang
2024-09-27 16:46:50 +08:00
parent b87eb65b3e
commit e6bd808a3d

View File

@@ -396,49 +396,6 @@ public class CoursePortalApi extends ApiBaseController{
String zipFilePath = "/home/www/elearning/upload/saveZip/" + courseName+"【作业】" + ".zip";
createZipFile(map, zipFilePath);
return success(zipFilePath);
// 创建一个临时文件用于存储ZIP文件
// File tempZipFile = new File("/home/www/elearning/upload/temp.zip");
//
// try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(tempZipFile))) {
// for (Map.Entry<String, String> e : map.entrySet()) {
// File fileToZip = new File(e.getValue());
// // 添加 ZIP 条目
// ZipEntry entry = new ZipEntry(e.getKey());
// entry.setSize(fileToZip.length());
//
// zos.putNextEntry(entry);
//
// try (FileInputStream fis = new FileInputStream(fileToZip)) {
// byte[] buffer = new byte[4096];
// int len;
// while ((len = fis.read(buffer)) > 0) {
// zos.write(buffer, 0, len);
// }
// }
//
// zos.closeEntry();
// }
// }
// // 将临时文件移动到指定位置
// Path source = tempZipFile.toPath();
// //生成uuid
//// String uuid = UUID.randomUUID().toString();
// Path destination = Paths.get("/home/www/elearning/upload/saveZip/" + courseName+"【作业】" + ".zip");
//
// // 确保目标目录存在
// Files.createDirectories(destination.getParent());
//
// // 删除目标文件如果已存在
// if (Files.exists(destination)) {
// Files.delete(destination);
// }
//
// // 移动文件
// Files.copy(source, destination, StandardCopyOption.REPLACE_EXISTING);
//
// // 返回文件路径给前端
// String filePath = destination.toAbsolutePath().toString();
// return success(filePath);
}
private static void createZipFile(Map<String, String> map, String zipFilePath) throws IOException {
try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFilePath))) {