Merge pull request #273 from Kitzanos/feature/GEPAFINBE-212

GEPAFINBE-212 (Fix filename decode issue for external doc upload API)
This commit is contained in:
rajeshkhore
2025-04-29 18:03:18 +05:30
committed by GitHub
3 changed files with 15 additions and 10 deletions

View File

@@ -37,6 +37,7 @@ import net.gepafin.tendermanagement.repositories.CompanyRepository;
import net.gepafin.tendermanagement.repositories.DocumentRepository;
import net.gepafin.tendermanagement.repositories.HubRepository;
import net.gepafin.tendermanagement.repositories.UserRepository;
import net.gepafin.tendermanagement.service.AmazonS3Service;
import net.gepafin.tendermanagement.service.ApplicationService;
import net.gepafin.tendermanagement.service.CompanyService;
import net.gepafin.tendermanagement.service.feignClient.AppointmentApiService;
@@ -141,6 +142,9 @@ public class AppointmentDao {
@Autowired
private ApplicationEvaluationServiceImpl applicationEvaluationService;
@Autowired
private AmazonS3Service amazonS3Service;
private final Map<Long, ExecutorService> executorMap = new ConcurrentHashMap<>();
private final ConcurrentHashMap<Long, ExecutorService> threadForDocumentMap = new ConcurrentHashMap<>();
@@ -982,12 +986,12 @@ public class AppointmentDao {
private File downloadFileFromS3(String fileUrl) throws Exception {
String key = extractS3KeyFromUrl(fileUrl);
File localFile = new File(GepafinConstant.TEMP_FILE_PATH + extractFileName(key));
String key = amazonS3Service.extractS3KeyFromUrl(fileUrl);
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 = s3Client.getObject(getObjectRequest).getObjectContent(); FileOutputStream outputStream = new FileOutputStream(localFile)) {
try (InputStream s3Stream = amazonS3Service.getFile(folderPath, key); FileOutputStream outputStream = new FileOutputStream(localFile)) {
s3Stream.transferTo(outputStream);
}
@@ -995,11 +999,6 @@ public class AppointmentDao {
return localFile;
}
private String extractS3KeyFromUrl(String url) {
return url.replace(s3Url, "");
}
private String extractFileName(String filePath) {
String[] parts = filePath.split("/");

View File

@@ -21,4 +21,5 @@ AmazonS3Service {
UploadFileOnAmazonS3Response copyFile(String fileName, String oldS3Path, String newS3Path);
String extractS3KeyFromUrl(String url);
}

View File

@@ -217,4 +217,9 @@ public class AmazonS3ServiceImpl implements AmazonS3Service {
}
}
public String extractS3KeyFromUrl(String url) {
return url.replace(s3Url, "");
}
}