fixed s3 call document download issue

This commit is contained in:
piyushkag
2024-10-29 21:31:35 +05:30
parent cd95c3fa86
commit 4e549e3e7a
5 changed files with 19 additions and 17 deletions

View File

@@ -119,8 +119,8 @@ public class ApplicationDao {
@Autowired
private ApplicationSignedDocumentRepository applicationSignedDocumentRepository;
@Value("${aws.s3.url.folder.signed.document}")
private String signedDocumentS3Folder;
// @Value("${aws.s3.url.folder.signed.document}")
// private String signedDocumentS3Folder;
@Value("${default.hub.uuid}")
private String defaultHubUuid;

View File

@@ -21,7 +21,6 @@ import net.gepafin.tendermanagement.util.DateTimeUtil;
import net.gepafin.tendermanagement.util.Utils;
import org.h2.util.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
@@ -94,14 +93,17 @@ public class CallDao {
@Autowired
private FormDao formDao;
@Value("${aws.s3.url.folder}")
private String s3Folder;
// @Value("${aws.s3.url.folder}")
// private String s3Folder;
@Autowired
private AmazonS3Service amazonS3Service;
@Autowired
private CriteriaFormFieldRepository criteriaFormFieldRepository;
@Autowired
private S3PathConfig s3PathConfig;
public CallResponse createCallStep1(CreateCallRequestStep1 createCallRequest, UserEntity userEntity) {
createCallRequest.setRegionId(userEntity.getRoleEntity().getRegion().getId());
@@ -127,6 +129,7 @@ public class CallDao {
ZipOutputStream zos = new ZipOutputStream(zipOutputStream)) {
for (DocumentEntity document : documents) {
String s3Folder = s3PathConfig.generateDocumentPath(DocumentSourceTypeEnum.CALL, callId, 0L);
try (InputStream fileInputStream = amazonS3Service.getFile(s3Folder, document.getFilePath())) {
String fileName = Utils.extractFileName(document.getFilePath());
ZipEntry zipEntry = new ZipEntry(fileName);

View File

@@ -8,10 +8,10 @@ import java.util.Map;
import java.util.function.Function;
import net.gepafin.tendermanagement.enums.DocOtherSourceTypeEnum;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
@@ -58,8 +58,8 @@ public class DelegationDao {
@Autowired
private S3PathConfig s3ConfigBean;
@Value("${aws.s3.url.folder.delegation}")
private String s3Folder;
// @Value("${aws.s3.url.folder.delegation}")
// private String s3Folder;
@Autowired
private UserCompanyDelegationRepository userCompanyDelegationRepository;
@@ -67,9 +67,9 @@ public class DelegationDao {
@Autowired
private Validator validator;
public ByteArrayOutputStream generateDocument(Map<String, String> placeholders, String templateName) {
try {
String s3Folder = s3ConfigBean.generateDocumentPathForOther(DocOtherSourceTypeEnum.USER_DELEGATION, 0L, 0L);
InputStream templateStream = amazonS3Service.getFile(s3Folder ,templateName);
XWPFDocument doc = loadTemplate(templateStream);
replacePlaceholders(doc, placeholders);

View File

@@ -7,7 +7,6 @@ import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
@@ -49,8 +48,8 @@ public class DocumentDao {
@Autowired
private ApplicationRepository applicationFormRepository;
@Value("${aws.s3.url.folder}")
private String s3Folder;
// @Value("${aws.s3.url.folder}")
// private String s3Folder;
public List<DocumentResponseBean> uploadFiles(List<MultipartFile> files, Long sourceId, DocumentSourceTypeEnum sourceType, DocumentTypeEnum fileType) {
List<DocumentEntity> documentEntities = new ArrayList<>();
@@ -141,7 +140,7 @@ public class DocumentDao {
try {
Long callId;
Long applicationId;
if(type.equals("APPLICATION")){
if(type.equals(DocumentSourceTypeEnum.APPLICATION)){
callId = applicationFormRepository.findCallIdById(id);
applicationId = id;
}else{