简体   繁体   中英

Can I have file and request body in an API

I have one condition where I need a multipart file as parameter and another request body in which some details related to file will be there, so is it possible for me to do that ?

@RequestParam(value = "name", required = false) String name,
            @RequestParam("file") MultipartFile file, @RequestBody CandidteEmailDTO dto

yes, it is possible to do. You should just ensure that you don't forget to declare enctype = "multipart/form-data", in your form tag.

Maybe you can take a look at this answer . I think that you need to change the @RequestParam to @FormDataParam

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM