updated code
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import com.amazonaws.services.s3.AmazonS3;
|
||||
import com.amazonaws.services.s3.AmazonS3Client;
|
||||
import com.amazonaws.services.s3.model.CopyObjectRequest;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
@@ -33,6 +34,7 @@ import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.net.URL;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -86,6 +88,9 @@ public class CompanyDocumentDao {
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
@Autowired
|
||||
private AmazonS3 amazonS3;
|
||||
|
||||
public List<CompanyDocumentResponseBean> uploadFileForCompany(HttpServletRequest request, Long userId, List<MultipartFile> files, Long companyId, Long documentCategoryId, CompanyDocumentTypeEnum companyDocumentSourceTypeEnum, LocalDateTime expirationDate,String name){
|
||||
DocumentCategoryEntity categoryEntity = categoryDao.validateCategory(documentCategoryId);
|
||||
validator.validateUserWithCompany(request,companyId);
|
||||
@@ -271,8 +276,11 @@ public class CompanyDocumentDao {
|
||||
s3Client.copyObject(copyRequest);
|
||||
log.info("File copied successfully from {} to {}", oldS3Path, newS3Path);
|
||||
|
||||
URL amazonS3Url = amazonS3.getUrl(bucketName, newS3Path);
|
||||
String fileUrl = amazonS3Url.toString();
|
||||
|
||||
DocumentEntity entity = new DocumentEntity();
|
||||
entity.setFilePath(newS3Path);
|
||||
entity.setFilePath(fileUrl);
|
||||
entity.setFileName(companyDocumentEntity.getFileName());
|
||||
entity.setSource(DocumentSourceTypeEnum.APPLICATION.getValue());
|
||||
entity.setType(documentTypeEnum.getValue());
|
||||
|
||||
Reference in New Issue
Block a user