Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring MVC file upload without multipart/form-data?

I have a path like POST /animals/1/images. I have read in the documentation that you can declare MultipartFile as a parameter and it will contain the file. But is this right? I mean, when you only have one file to upload (or an array of files) do I need to use the content type multipart/form-data? If not, how should the method signature be?

like image 600
LuckyLuke Avatar asked Jul 10 '26 21:07

LuckyLuke


1 Answers

You can use this code fragment:

@POST
@Path("/uploadfile")
public void upload(File file) {
  //TODO code goes here


}
like image 101
Tarcisio Cardoso Avatar answered Jul 13 '26 13:07

Tarcisio Cardoso



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!