I have a Spring Boot 2, reactive webflux web service, which persists uploaded, multipart fileparts to MongoDB's GridFS. This is working properly. Today, a request was made to include metadata for the files being added to GridFS. Unfortunately, I have not been able to get it to work with my functional/non-annotated web service. I would appreciate any suggestions or nudges in the correct direction. Here are the details:
An example of the request being sent to my endpoint:
curl -X "POST" "http://localhost:8080/api/maps" \
-H 'Content-Type: multipart/form-data; charset=utf-8; boundary=__X_BOUNDARY__'"'"'' \
-F "files=@animage.jpg" \
-F "metadata={\"tenantId\":\"598b53702f52f9\",\"projectId\":\"59c0a78d6212dc\"}
Here is my current service that works without the metadata in the request, above:
override fun upload(fluxFileParts: Flux<FilePart>): Flux<Map<String, String>> =
fluxFileParts
.flatMap { filePart ->
reactiveGridFsTemplate.store(
filePart.content(),
filePart.filename(),
kMediaTypeMap.getValue(filePart.filename().getFileExtension())
)
.map { objectId ->
mapOf("objectId" to objectId.toHexString())
}
}
Basically, I am trying to be able to implement something like the following. If I were using annotations, the @RequestPart would provide the strongly typed object.
override fun uploadWithProjectMetadata(
fluxFileParts: Flux<FilePart>,
metadata: SliderUploadMetadata
//@RequestPart("files") fluxFileParts: Flux<FilePart>,
//@RequestPart metadata: SliderUploadMetadata
): Flux<Map<String, String>>
I'd appreciate your help... I have been going around and around for several hours and am not making any progress... Arggg... frustrating! :)