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 web project i'm getting uploaded file as Multipart file.I have to convert it to a File(io) ,there fore I can call this image storing service(Cloudinary).They only take type (File).
I have done so many searches but failed.If anybody knows a good standard way please let me know?
Thnx
Best Answer
You can get the content of a
MultipartFile
by using thegetBytes
method and you can write to the file usingFiles.newOutputStream()
:You can also use the transferTo method: