change url

This commit is contained in:
gulnaz 2024-10-02 09:31:47 +03:00
parent 6c9ecf7458
commit ca10109318
2 changed files with 5 additions and 9 deletions

View file

@ -30,18 +30,14 @@ public class S3Service {
} }
} }
public void putFile(Path filePath, String key) throws FileUploadException { public String putFile(Path filePath, String key) throws FileUploadException {
try { try {
outClient.putObject(outBucketName, generateResourceName(outBucketName, key), outClient.putObject(outBucketName, key, filePath.toFile());
filePath.toFile()); return String.join("/", "s3:/", outBucketName, key);
} }
catch (AmazonServiceException e) { catch (AmazonServiceException e) {
// todo message // todo message
throw new FileUploadException(e); throw new FileUploadException(e);
} }
} }
private static String generateResourceName(String bucketName, String key) {
return String.join("/", bucketName, key);
}
} }

View file

@ -118,9 +118,9 @@ public class FileUploadService {
sendMessage(outErrorTopic.name(), downloadRequest, kafkaTemplate); sendMessage(outErrorTopic.name(), downloadRequest, kafkaTemplate);
} }
else { else {
s3Service.putFile(filePath, fileUrl.fileName()); String fileRef = s3Service.putFile(filePath, fileUrl.fileName());
downloadRequest.fileInfo().setFileUrl(fileUrl.fileName()); downloadRequest.fileInfo().setFileUrl(fileRef);
downloadRequest.fileInfo().setFileStatus(FileStatus.FILE_STATUS_03); downloadRequest.fileInfo().setFileStatus(FileStatus.FILE_STATUS_03);
sendMessage(outSuccessTopic.name(), downloadRequest, kafkaTemplate); sendMessage(outSuccessTopic.name(), downloadRequest, kafkaTemplate);
} }