Note that there are some explanatory texts on larger screens.

plurals
  1. POconvert CommonsMultipartFile to file
    text
    copied!<p>I am using a plugin that uploads files as a CommonsMultipartFile. The upload works fine, but I am trying to use another plugin to read the files header (the mp3 header) but it will not take CommonsMultipartFile, only regular files. Is there a way to either convert the CommonsMultipartFile to a file or have some other work around. I've tried copying the file from where it gets uploaded from, but it doesn't seem to work. here is what i have so far:</p> <pre><code>if (request instanceof MultipartHttpServletRequest) { MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest)request; CommonsMultipartFile file = (CommonsMultipartFile)multiRequest.getFile("files"); moveFile(file) } private moveFile(CommonsMultipartFile file){ def userId = getUserId() def userGuid = SecUser.get(userId.id).uid def webRootDir = servletContext.getRealPath("/") def userDir = new File(webRootDir, "/myUsers/${userGuid}/music") userDir.mkdirs() file.transferTo( new File( userDir,file.originalFilename)) def myFile = new File( "/myUsers/${userGuid}/music/" + file.originalFilename) AudioFile audioFile = AudioFileIO.read(file); //AudioFile is expecting a file, not a CommonsMultipartFile } </code></pre> <p>When i do this, though, i get this error: </p> <p>groovy.lang.MissingMethodException: No signature of method: static org.jaudiotagger.audio.AudioFileIO.read() is applicable for argument types: (org.springframework.web.multipart.commons.CommonsMultipartFile) values: [org.springframework.web.multipart.commons.CommonsMultipartFile@10a531]</p> <p>Thanks jason</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload