I using developing a RESTFul web service using Maven and Spring Roo.
In my configuration xml file I defined a multipartResolver
bean because I am uploading files of 300KB:
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="400000" />
<property name="maxInMemorySize" value="400000" />
</bean>
The files are uploaded successfully and pushed into a stack. These file are CommonsMultipartFile
or MultipartFile
objects (I have the same phenomenon for both type of objects). Once I pop a file, I can call getSize()
method and I can verify that the size of the file is correct. But once I call getInputStream()
I get the following error: File has been moved - cannot be read again.
Did I do something wrong in my multipartResolver
declaration? Is there any other reason to have this error?
Thank you
The call to getInputStream() is being recognized as a request to get the input stream of the file on the client-side. And as the file has been already uploaded it says "file has been moved - cannot read again"
also what are you trying to do by calling getInputStream()? If you want to read the uploaded file, create a new FileInputStream with the path of the uploaded location and access the file contents.