change url
This commit is contained in:
parent
6c9ecf7458
commit
ca10109318
2 changed files with 5 additions and 9 deletions
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue