In my method I have a MultipartFile (instance of StreamingMultipartFile) ( org.springframework.web.multipart.MultipartFile
) passed as an argument.
Inside this method I need to get a copy of the file, as its InputStream is to be read by another method and the file is to be passed itself after that. I tried to reset the InputStream of the file but it doesn't work.
Also I tried to use GSON library and SerializationUtils methods from org.springframework.util
package to serialize/deserialize but it doesn't succeeded as the class doesn't have no-args constructor.
So how the copy of such file can be obtained at all?
I have found next solution - create custom class with next fields:
private final byte[] fileContent;
private final String fileName;
Also the class should implement the MultipartFile
interface and override all methods based on specified fields accordingly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.