sistemato servizio di salvataggio delle immagini
This commit is contained in:
@@ -1025,9 +1025,9 @@ public class ProductServices {
|
||||
String filePath = UtilityString.isNullOrEmpty(requestDto.getPathFile()) ? setup.get("FILE_FILTER") : requestDto.getPathFile();
|
||||
|
||||
if (filePath == null) {
|
||||
// mtbAartList.add(
|
||||
// prepareEntityForImportFoto(requestDto.getRawContentB64().toLowerCase())
|
||||
// );
|
||||
mtbAartList.add(
|
||||
prepareEntityForImportFoto(requestDto.getFileName(), requestDto.getRawContentB64())
|
||||
);
|
||||
} else {
|
||||
File directory = new File(filePath);
|
||||
|
||||
@@ -1057,6 +1057,13 @@ public class ProductServices {
|
||||
|
||||
private MtbAart prepareEntityForImportFoto(File file) throws Exception {
|
||||
String fileName = file.getName().toLowerCase();
|
||||
byte[] content = FileUtils.readFileToByteArray(file);
|
||||
String b64File = Base64.encodeBase64String(content);
|
||||
|
||||
return prepareEntityForImportFoto(fileName, b64File);
|
||||
}
|
||||
|
||||
private MtbAart prepareEntityForImportFoto(String fileName, String b64File) throws Exception {
|
||||
List<String> validExtensions = Arrays.asList(".jpg", ".jpeg", ".png", ".gif");
|
||||
int extensionIndex = fileName.lastIndexOf(".");
|
||||
String codMart;
|
||||
@@ -1079,9 +1086,6 @@ public class ProductServices {
|
||||
MtbAartLink mtbAartLink = new MtbAartLink();
|
||||
mtbAartLink.setCodMart(codMart);
|
||||
mtbAartLink.setPathLink(fileName);
|
||||
|
||||
byte[] content = FileUtils.readFileToByteArray(file);
|
||||
String b64File = Base64.encodeBase64String(content);
|
||||
mtbAartLink.setB64Content(b64File);
|
||||
mtbAartLink.setDescrizioneLink("Immagine prodotto " + codMart);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user