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
You can get the content of
multipartFile
by using thegetBytes
method and you can create an instance of theFile
class by using theFileOutputStream
class.You can also use the transferTo method: