How to convert a multipart file to File?

后端 未结 9 2000
有刺的猬
有刺的猬 2020-11-29 16:44

Can any one tell me what is a the best way to convert a multipart file (org.springframework.web.multipart.MultipartFile) to File (java.io.File) ?

In my spring mvc w

9条回答
  •  难免孤独
    2020-11-29 17:43

    Although the accepted answer is correct but if you are just trying to upload your image to cloudinary, there's a better way:

    Map upload = cloudinary.uploader().upload(multipartFile.getBytes(), ObjectUtils.emptyMap());
    

    Where multipartFile is your org.springframework.web.multipart.MultipartFile.

提交回复
热议问题