Untitled
vas
plain_text
9 months ago
1.3 kB
4
Indexable
public Mono<JsonNode> storesImageFiles(List<FilePart> imageFiles) {
List<Mono<String>> urlMonos = new ArrayList<>();
String currentTime = getCurrentTime();
logger.info("imageFiles: " + imageFiles);
for (FilePart imageFile : imageFiles) {
MultipartBodyBuilder builder = new MultipartBodyBuilder();
builder.part("file", imageFile);
String endpoint = serverpath.getFileMgmtApi() + serverpath.getS3Bucket() +GoalConstants.ORION_FOLDER_PATH + getCurrentDate();
String filename = "/"+currentTime +"_"+ imageFile.filename(); // Get the filename from the imageFile
Mono<String> s3UrlMono = webClient.put().uri(endpoint + filename)
.contentType(MediaType.MULTIPART_FORM_DATA)
.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA.toString())
.body(BodyInserters.fromMultipartData(builder.build())).retrieve().bodyToMono(JsonNode.class)
.map(objectResponse -> {
String s3Url = objectResponse.get("message").asText().split("=> ")[1];
return s3Url;
});
urlMonos.add(s3UrlMono);
}Editor is loading...
Leave a Comment