Update file saving code

This commit is contained in:
2025-03-16 11:32:18 -04:00
parent 2439c9b3cb
commit de23a8bfa6
3 changed files with 16 additions and 6 deletions

View File

@@ -2,6 +2,7 @@ package com.mattrixwv.raidbuilder.service;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
@@ -41,7 +42,8 @@ public class GameClassService{
Path filePath = Paths.get(uploadFileDirectory + "/gameClassIcons").resolve(fileName);
try{
file.transferTo(filePath);
//file.transferTo(filePath);
Files.copy(file.getInputStream(), filePath);
gameClass.setGameClassIcon(fileName);
}
catch(Exception error){
@@ -49,6 +51,7 @@ public class GameClassService{
throw new RuntimeException("Error uploading file: " + error.getMessage(), error);
}
}
return gameClassRepository.save(gameClass);
}
@@ -69,7 +72,8 @@ public class GameClassService{
String fileName = UUID.randomUUID().toString() + "--" + file.getOriginalFilename();
Path filePath = Paths.get(uploadFileDirectory + "/gameClassIcons").resolve(fileName);
try{
file.transferTo(filePath);
//file.transferTo(filePath);
Files.copy(file.getInputStream(), filePath);
gameClass.setGameClassIcon(fileName);
}
catch(Exception error){

View File

@@ -2,6 +2,7 @@ package com.mattrixwv.raidbuilder.service;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
@@ -43,7 +44,8 @@ public class GameService{
String fileName = UUID.randomUUID().toString() + "--" + file.getOriginalFilename();
Path filePath = Paths.get(uploadFileDirectory + "/gameIcons").resolve(fileName);
try{
file.transferTo(filePath);
//file.transferTo(filePath);
Files.copy(file.getInputStream(), filePath);
game.setGameIcon(fileName);
}
catch(Exception error){
@@ -71,7 +73,8 @@ public class GameService{
String fileName = UUID.randomUUID().toString() + "--" + file.getOriginalFilename();
Path filePath = Paths.get(uploadFileDirectory + "/gameIcons").resolve(fileName);
try{
file.transferTo(filePath);
//file.transferTo(filePath);
Files.copy(file.getInputStream(), filePath);
game.setGameIcon(fileName);
}
catch(Exception error){

View File

@@ -2,6 +2,7 @@ package com.mattrixwv.raidbuilder.service;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
@@ -49,7 +50,8 @@ public class RaidGroupService{
Path filePath = Paths.get(uploadFileDirectory + "/raidGroupIcons").resolve(fileName);
try{
file.transferTo(filePath);
//file.transferTo(filePath);
Files.copy(file.getInputStream(), filePath);
raidGroup.setRaidGroupIcon(fileName);
}
catch(Exception error){
@@ -90,7 +92,8 @@ public class RaidGroupService{
String fileName = UUID.randomUUID().toString() + "--" + file.getOriginalFilename();
Path filePath = Paths.get(uploadFileDirectory + "/raidGroupIcons").resolve(fileName);
try{
file.transferTo(filePath);
//file.transferTo(filePath);
Files.copy(file.getInputStream(), filePath);
raidGroup.setRaidGroupIcon(fileName);
}
catch(Exception error){