Merge pull request #274 from Kitzanos/fix-filename-decode-issue-prod
Cherry-pick (Fix filename decode issue for external doc upload API)
This commit is contained in:
@@ -37,6 +37,7 @@ import net.gepafin.tendermanagement.repositories.CompanyRepository;
|
|||||||
import net.gepafin.tendermanagement.repositories.DocumentRepository;
|
import net.gepafin.tendermanagement.repositories.DocumentRepository;
|
||||||
import net.gepafin.tendermanagement.repositories.HubRepository;
|
import net.gepafin.tendermanagement.repositories.HubRepository;
|
||||||
import net.gepafin.tendermanagement.repositories.UserRepository;
|
import net.gepafin.tendermanagement.repositories.UserRepository;
|
||||||
|
import net.gepafin.tendermanagement.service.AmazonS3Service;
|
||||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||||
import net.gepafin.tendermanagement.service.CompanyService;
|
import net.gepafin.tendermanagement.service.CompanyService;
|
||||||
import net.gepafin.tendermanagement.service.feignClient.AppointmentApiService;
|
import net.gepafin.tendermanagement.service.feignClient.AppointmentApiService;
|
||||||
@@ -141,6 +142,9 @@ public class AppointmentDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationEvaluationServiceImpl applicationEvaluationService;
|
private ApplicationEvaluationServiceImpl applicationEvaluationService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AmazonS3Service amazonS3Service;
|
||||||
|
|
||||||
private final Map<Long, ExecutorService> executorMap = new ConcurrentHashMap<>();
|
private final Map<Long, ExecutorService> executorMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private final ConcurrentHashMap<Long, ExecutorService> threadForDocumentMap = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<Long, ExecutorService> threadForDocumentMap = new ConcurrentHashMap<>();
|
||||||
@@ -982,12 +986,12 @@ public class AppointmentDao {
|
|||||||
|
|
||||||
private File downloadFileFromS3(String fileUrl) throws Exception {
|
private File downloadFileFromS3(String fileUrl) throws Exception {
|
||||||
|
|
||||||
String key = extractS3KeyFromUrl(fileUrl);
|
String key = amazonS3Service.extractS3KeyFromUrl(fileUrl);
|
||||||
File localFile = new File(GepafinConstant.TEMP_FILE_PATH + extractFileName(key));
|
String fileName = extractFileName(key);
|
||||||
|
String folderPath = key.substring(0, key.lastIndexOf("/"));
|
||||||
|
File localFile = new File(GepafinConstant.TEMP_FILE_PATH + fileName);
|
||||||
|
|
||||||
GetObjectRequest getObjectRequest = new GetObjectRequest(OLD_BUCKET, key);
|
try (InputStream s3Stream = amazonS3Service.getFile(folderPath, key); FileOutputStream outputStream = new FileOutputStream(localFile)) {
|
||||||
|
|
||||||
try (InputStream s3Stream = s3Client.getObject(getObjectRequest).getObjectContent(); FileOutputStream outputStream = new FileOutputStream(localFile)) {
|
|
||||||
s3Stream.transferTo(outputStream);
|
s3Stream.transferTo(outputStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -995,11 +999,6 @@ public class AppointmentDao {
|
|||||||
return localFile;
|
return localFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String extractS3KeyFromUrl(String url) {
|
|
||||||
|
|
||||||
return url.replace(s3Url, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
private String extractFileName(String filePath) {
|
private String extractFileName(String filePath) {
|
||||||
|
|
||||||
String[] parts = filePath.split("/");
|
String[] parts = filePath.split("/");
|
||||||
|
|||||||
@@ -21,4 +21,5 @@ AmazonS3Service {
|
|||||||
|
|
||||||
UploadFileOnAmazonS3Response copyFile(String fileName, String oldS3Path, String newS3Path);
|
UploadFileOnAmazonS3Response copyFile(String fileName, String oldS3Path, String newS3Path);
|
||||||
|
|
||||||
|
String extractS3KeyFromUrl(String url);
|
||||||
}
|
}
|
||||||
@@ -217,4 +217,9 @@ public class AmazonS3ServiceImpl implements AmazonS3Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String extractS3KeyFromUrl(String url) {
|
||||||
|
|
||||||
|
return url.replace(s3Url, "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user