|
|
@@ -6,6 +6,7 @@ import java.io.IOException;
|
|
|
import java.math.BigInteger;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.Paths;
|
|
|
+import java.nio.file.StandardCopyOption;
|
|
|
import java.sql.Timestamp;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.Year;
|
|
|
@@ -207,7 +208,7 @@ public class ProceduresController {
|
|
|
@PostMapping("/procedure/files/{id}")
|
|
|
@ResponseBody
|
|
|
public HashMap<String, Object> updateInstanciaTascaEvidencia(@PathVariable BigInteger id, @RequestParam Map<String,String> params,
|
|
|
- @RequestParam(required = true) List<MultipartFile> evidencias, @RequestParam String usuari) throws IllegalStateException, IOException {
|
|
|
+ @RequestBody(required = true) List<File> evidencias, @RequestParam String usuari) throws IllegalStateException, IOException {
|
|
|
HashMap<String, Object> model = new HashMap<>();
|
|
|
Usuari u = us.findByUsername(usuari);
|
|
|
|
|
|
@@ -225,20 +226,19 @@ public class ProceduresController {
|
|
|
if(evidencias.size() > 1) {
|
|
|
fileName = (newTask ? it.getIdInstanciaTasca().add(new BigInteger("1")).toString() : it.getIdInstanciaTasca().toString()) + ".zip";
|
|
|
try (ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(filePath+fileName))) {
|
|
|
- for(MultipartFile f : evidencias) {
|
|
|
- File tempFile = File.createTempFile("saic", "temp");
|
|
|
- tempFile.deleteOnExit();
|
|
|
- f.transferTo(tempFile);
|
|
|
- zipOut.putNextEntry(new ZipEntry(f.getOriginalFilename()));
|
|
|
- Files.copy(Paths.get(tempFile.getAbsolutePath()), zipOut);
|
|
|
- }
|
|
|
+ for (File f : evidencias) {
|
|
|
+ zipOut.putNextEntry(new ZipEntry(f.getName()));
|
|
|
+ Files.copy(f.toPath(), zipOut);
|
|
|
+ zipOut.closeEntry();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else if(evidencias.size() == 1){
|
|
|
- MultipartFile evidencia = evidencias.get(0);
|
|
|
+ File evidencia = evidencias.get(0);
|
|
|
fileName = (newTask ? it.getIdInstanciaTasca().add(new BigInteger("1")).toString() : it.getIdInstanciaTasca().toString()) + "." +
|
|
|
- FilenameUtils.getExtension(evidencia.getOriginalFilename());
|
|
|
- evidencia.transferTo(new File(filePath+fileName));
|
|
|
+ FilenameUtils.getExtension(evidencia.getName());
|
|
|
+ File destino = new File(filePath, fileName);
|
|
|
+ Files.copy(evidencia.toPath(), destino.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
|
|
}
|
|
|
else {
|
|
|
model.put("ammount", "0");
|
|
|
@@ -280,7 +280,7 @@ public class ProceduresController {
|
|
|
* @return The name of the view to render
|
|
|
*/
|
|
|
@PostMapping("/procedure/{id}")
|
|
|
- public HashMap<String, Object> updateInstanciaTasca(@PathVariable BigInteger id, @RequestParam Map<String,String> params,
|
|
|
+ public HashMap<String, Object> updateInstanciaTasca(@PathVariable BigInteger id, @RequestBody Map<String,String> params,
|
|
|
@RequestParam(required = false) List<MultipartFile> evidencias, @RequestParam String usuari) throws IllegalStateException, IOException, InterruptedException {
|
|
|
HashMap<String, Object> model = new HashMap<>();
|
|
|
Usuari u = us.findByUsername(usuari);
|