Handle file stream not closing
This commit is contained in:
@@ -2,6 +2,7 @@ package com.mattrixwv.raidbuilder.service;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
@@ -41,9 +42,9 @@ public class GameClassService{
|
||||
String fileName = UUID.randomUUID().toString() + "--" + file.getOriginalFilename();
|
||||
Path filePath = Paths.get(uploadFileDirectory + "/gameClassIcons").resolve(fileName);
|
||||
|
||||
try{
|
||||
try(InputStream is = file.getInputStream()){
|
||||
//file.transferTo(filePath);
|
||||
Files.copy(file.getInputStream(), filePath);
|
||||
Files.copy(is, filePath);
|
||||
gameClass.setGameClassIcon(fileName);
|
||||
}
|
||||
catch(Exception error){
|
||||
@@ -71,9 +72,9 @@ public class GameClassService{
|
||||
//Upload the new file
|
||||
String fileName = UUID.randomUUID().toString() + "--" + file.getOriginalFilename();
|
||||
Path filePath = Paths.get(uploadFileDirectory + "/gameClassIcons").resolve(fileName);
|
||||
try{
|
||||
try(InputStream is = file.getInputStream()){
|
||||
//file.transferTo(filePath);
|
||||
Files.copy(file.getInputStream(), filePath);
|
||||
Files.copy(is, filePath);
|
||||
gameClass.setGameClassIcon(fileName);
|
||||
}
|
||||
catch(Exception error){
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mattrixwv.raidbuilder.service;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
@@ -43,9 +44,9 @@ public class GameService{
|
||||
if(file != null){
|
||||
String fileName = UUID.randomUUID().toString() + "--" + file.getOriginalFilename();
|
||||
Path filePath = Paths.get(uploadFileDirectory + "/gameIcons").resolve(fileName);
|
||||
try{
|
||||
try(InputStream is = file.getInputStream()){
|
||||
//file.transferTo(filePath);
|
||||
Files.copy(file.getInputStream(), filePath);
|
||||
Files.copy(is, filePath);
|
||||
game.setGameIcon(fileName);
|
||||
}
|
||||
catch(Exception error){
|
||||
@@ -72,9 +73,9 @@ public class GameService{
|
||||
//Upload the new file
|
||||
String fileName = UUID.randomUUID().toString() + "--" + file.getOriginalFilename();
|
||||
Path filePath = Paths.get(uploadFileDirectory + "/gameIcons").resolve(fileName);
|
||||
try{
|
||||
try(InputStream is = file.getInputStream()){
|
||||
//file.transferTo(filePath);
|
||||
Files.copy(file.getInputStream(), filePath);
|
||||
Files.copy(is, filePath);
|
||||
game.setGameIcon(fileName);
|
||||
}
|
||||
catch(Exception error){
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mattrixwv.raidbuilder.service;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
@@ -49,9 +50,9 @@ public class RaidGroupService{
|
||||
String fileName = UUID.randomUUID().toString() + "--" + file.getOriginalFilename();
|
||||
Path filePath = Paths.get(uploadFileDirectory + "/raidGroupIcons").resolve(fileName);
|
||||
|
||||
try{
|
||||
try(InputStream is = file.getInputStream()){
|
||||
//file.transferTo(filePath);
|
||||
Files.copy(file.getInputStream(), filePath);
|
||||
Files.copy(is, filePath);
|
||||
raidGroup.setRaidGroupIcon(fileName);
|
||||
}
|
||||
catch(Exception error){
|
||||
@@ -91,9 +92,9 @@ public class RaidGroupService{
|
||||
//Upload the new file
|
||||
String fileName = UUID.randomUUID().toString() + "--" + file.getOriginalFilename();
|
||||
Path filePath = Paths.get(uploadFileDirectory + "/raidGroupIcons").resolve(fileName);
|
||||
try{
|
||||
try(InputStream is = file.getInputStream()){
|
||||
//file.transferTo(filePath);
|
||||
Files.copy(file.getInputStream(), filePath);
|
||||
Files.copy(is, filePath);
|
||||
raidGroup.setRaidGroupIcon(fileName);
|
||||
}
|
||||
catch(Exception error){
|
||||
|
||||
Reference in New Issue
Block a user