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