diff --git a/module-flow/src/main/java/net/savantly/nexus/flow/api/FlowApi.java b/module-flow/src/main/java/net/savantly/nexus/flow/api/FlowApi.java index b665f58..807c573 100644 --- a/module-flow/src/main/java/net/savantly/nexus/flow/api/FlowApi.java +++ b/module-flow/src/main/java/net/savantly/nexus/flow/api/FlowApi.java @@ -20,6 +20,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import jakarta.servlet.http.HttpServletRequest; import lombok.RequiredArgsConstructor; import lombok.extern.log4j.Log4j2; import net.savantly.nexus.flow.dom.files.FileEntities; @@ -86,12 +87,17 @@ public ResponseEntity submitFormJson(@PathVariable String formId, @RequestBody M } @PostMapping(value = "/files/{organizationId}") - public ResponseEntity createFile(@RequestParam("file") MultipartFile file, @PathVariable String organizationId) { + public ResponseEntity createFile(@RequestParam("file") MultipartFile file, @PathVariable String organizationId, + HttpServletRequest request) { log.info("Requested to upload file"); try { var entity = files.uploadFile(organizationId, file); log.info("File uploaded: {}", entity); - var dto = new FileEntityDto().setId(entity.getId()); + + // get the url used to download the file + var url = request.getRequestURL().toString().replace(organizationId, entity.getId()); + + var dto = new FileEntityDto().setId(entity.getId()).setUrl(url); return ResponseEntity.ok(dto); } catch (IOException e) { log.error("Failed to upload file", e); diff --git a/module-flow/src/main/java/net/savantly/nexus/flow/dom/files/FileEntityDto.java b/module-flow/src/main/java/net/savantly/nexus/flow/dom/files/FileEntityDto.java index 319317c..2fb1e31 100644 --- a/module-flow/src/main/java/net/savantly/nexus/flow/dom/files/FileEntityDto.java +++ b/module-flow/src/main/java/net/savantly/nexus/flow/dom/files/FileEntityDto.java @@ -7,4 +7,5 @@ @Accessors(chain = true) public class FileEntityDto { private String id; + private String url; }