You don't mention which implementation of MultipartFile you are using, but if it exists on disk, it probably doesn't have the original file name (hence the method getOriginalFilename). What you probably want to do is move the file from its temporary storage location to a known location and manipulate the file there.
I'm uploading the zip file as an instance of multipartfile in my Spring's Controller, the controller passes on the file to the workflow, where I'm trying to validate the contents of the zip file. In order to validate the contents, I'm first creating an instance of the file,
File tempFile = new File("C:/workspace/tempData/" + fileName);
this creates a file with the originalFileName, which maybe 'sample.zip'. When I debug, the 'fileName' exists,
also, it says the file is created, it provides me with the absolutepath as well.....,
but, to validate the contents of a Zip from a multipartfile, do you have any other suggestions...
I haven't used Spring, but a quick look at the documentation validates what I said above:
The file contents are either stored in memory or temporarily on disk. In either case, the user is responsible for copying file contents to a session-level or persistent store as and if desired. The temporary storages will be cleared at the end of request processing.
There are methods in MultipartFile to facilitate moving the data, namely getInputStream and transferTo. Once you've copied the file, you are free to do your validation.