MultipartFile
Method summary | |
---|---|
byte[] |
getBytes() Returns the contents of the file as a byte array. |
String |
getContentType() Returns the content type of the file. |
InputStream |
getInputStream() Returns the InputStream to read the contents of the file. |
String |
getName() Returns the name of the parameter in multipart form. |
String |
getOriginalFilename() Returns the original filename on the client's filesystem. |
long |
getSize() Returns the size of the file, in bytes. |
boolean |
isEmpty() Returns whether the uploaded file is empty, that is, no file is selected in the multipart form or the selected file has no content. |
void |
transferTo(File dest) Transfer the received file to the given destination file. |
method details |
---|
getName
String getName ()
-
Returns the name of the parameter in multipart form.
-
- return:
-
the name of the parameter (none
null
or empty)
getOriginalFilename
String skew getOriginalFilename ( )
-
Returns the original filename on the client's filesystem.
This may contain path information depending on the browser used, but it usually does not work with anything other than Opera.
-
- return:
- the original filename, or an empty string if no file is selected in multipart form
getContentType
String getContentType ()
-
Returns the content type of the file.
-
- return:
-
content
null
-type, or if not defined (or multipart not selected file form)
isEmpty
boolean isEmpty ()
-
Returns whether the uploaded file is empty, that is, no file is selected in the multipart form or the selected file has no content.
-
getSize
长getSize()
-
Returns the size of the file, in bytes.
-
- return:
- the size of the file, if empty or 0
getBytes
byte[]getBytes() throw IOException
-
Returns the contents of the file as a byte array.
-
- return:
- the contents of the file as bytes, if empty or an empty byte array
- throws:
-
IOException
In case of access error (if temporary storage fails)
getInputStream
InputStream getInputStream() throw IOException
-
Returns the InputStream to read the contents of the file. The user is responsible for closing the stream.
-
- return:
- the content stream of the file, if empty or empty stream
- throws:
-
IOException
In case of access error (if temporary storage fails)
transferTo
void transferTo ( file table) 抛出IOException,IllegalStateException
-
Transfer the received file to the given destination file.
This can move the file to the file system, copy the file to the file system, or save the memory contents to the target file. If the target file already exists, it will be deleted.
If the file is moved to the filesystem, this operation cannot be called again. Therefore, calling this method can apply to any storage mechanism only once.
-
- parameter:
-
dest
--Target file - throws:
-
IOException
- errors in reading or writing -
IllegalStateException
If the file has been moved on the file system and is unavailable for another transfer