In camel, upload file using multipart/form-data.
Receiving request in the below format. Need the get the fileType, file and file_name from the Exchange request.
I am able to convert to string using exchange.getIn().getBody(String.class). Can we convert the request body to Json format? Please guide me on this.
`BodyType: org.apache.camel.converter.stream.InputStreamCache,
Body:
——WebKitFormBoundaryYHpyaSsR8EVC6uFG
Content-Disposition: form-data; name=”fileType”
X1
——WebKitFormBoundaryYHpyaSsR8EVC6uFG
Content-Disposition: form-data; name=”file”
ARBJrbfesz9MmfXNBbm5SdTAAQBhmK3vjHs2nlW7i5Lr5oP39QSR/3z29IcrkOqv4i3SXDNaQ3/irEaEsirMKAJzySvlqAvWe0qXOWnBgoHd3v0c+fI1KXEsdDH1qNzs8X5VrOIFrlfaOUu3zVI50ykLe0tIson5WKsdglDQoSuiSStbBKQWutCW85kfd4xGHMzB2ynyfgxumrifpgEYsWELcBPkFGiOlcGynXxCqwOCfcf7VO839W0NM/UmCWK/gkeP8Ms8uO3cq1yZ1YKDsg070+73KOCr3GdvZclNfLt57KQPrlBdp5HGblq4Av36QMQA+wExNkawJqeMs6jwUTwWDScDk//TKarHD9iRQLPecwhDwUfHp744uh21DFngUf1dYvyHNRhczRXgreQWCkO80EuziE27ahYVTTI0ez5iauSE
——WebKitFormBoundaryYHpyaSsR8EVC6uFG
Content-Disposition: form-data; name=”file_name”
new.txt
`
In camel, upload file using multipart/form-data.
Receiving request in the below format. Need the get the fileType, file and file_name from the Exchange request.
I am able to convert to string using exchange.getIn().getBody(String.class). Can we convert the request body to Json format? Please guide me on this.
`BodyType: org.apache.camel.converter.stream.InputStreamCache,
Body:
——WebKitFormBoundaryYHpyaSsR8EVC6uFG
Content-Disposition: form-data; name=”fileType”
X1
——WebKitFormBoundaryYHpyaSsR8EVC6uFG
Content-Disposition: form-data; name=”file”
ARBJrbfesz9MmfXNBbm5SdTAAQBhmK3vjHs2nlW7i5Lr5oP39QSR/3z29IcrkOqv4i3SXDNaQ3/irEaEsirMKAJzySvlqAvWe0qXOWnBgoHd3v0c+fI1KXEsdDH1qNzs8X5VrOIFrlfaOUu3zVI50ykLe0tIson5WKsdglDQoSuiSStbBKQWutCW85kfd4xGHMzB2ynyfgxumrifpgEYsWELcBPkFGiOlcGynXxCqwOCfcf7VO839W0NM/UmCWK/gkeP8Ms8uO3cq1yZ1YKDsg070+73KOCr3GdvZclNfLt57KQPrlBdp5HGblq4Av36QMQA+wExNkawJqeMs6jwUTwWDScDk//TKarHD9iRQLPecwhDwUfHp744uh21DFngUf1dYvyHNRhczRXgreQWCkO80EuziE27ahYVTTI0ez5iauSE
——WebKitFormBoundaryYHpyaSsR8EVC6uFG
Content-Disposition: form-data; name=”file_name”
new.txt
`
tried to read the InputStreamCache multipart/form-data – how to ready this type of request from Camel Exchange request
MultipartRequest multipartRequest = exchange.getIn().getBody(MultipartRequest.class);
log.info("log multipartRequest {}", multipartRequest);
MultipartFile multipartFile = exchange.getIn().getBody(MultipartFile.class);
log.info("log multipartFile {}", multipartFile);
InputStreamCache inputStreamCache = exchange.getIn().getBody(InputStreamCache.class);
log.info("log inputStreamCache {}", inputStreamCache);
vrdhrjn353 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.