接口 MultipartFile
- 所有超级接口:
cn.taketoday.core.io.InputStreamSource,Multipart,Serializable
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 storage will be cleared at the end of request processing.
- 从以下版本开始:
- 2018-07-11 13:02:52
- 作者:
- Harry Yang
- 另请参阅:
-
方法概要
修饰符和类型方法说明voiddelete()Deletes the underlying storage for a file item, including deleting any associated temporary disk file.byte[]getBytes()Returns the contents of the file item as an array of bytes.Return the content type of the file.getName()Return the name of the parameter in the multipart form.Return the original filename in the client's filesystem.Get original resourcedefault cn.taketoday.core.io.ResourceReturn a Resource representation of this MultipartFile.longgetSize()Return the size of the file in bytes.booleanisEmpty()Return whether the uploaded file is empty, that is, either no file has been chosen in the multipart form or the chosen file has no content.voidtransferTo(File dest) Transfer the received file to the given destination file.default voidtransferTo(Path dest) Transfer the received file to the given destination file.从接口继承的方法 cn.taketoday.core.io.InputStreamSource
getInputStream, getReader, getReader, readableChannel从接口继承的方法 cn.taketoday.web.multipart.Multipart
getHeaders, getValue, isFormField
-
方法详细资料
-
getContentType
Return the content type of the file.- 返回:
- the content type, or
nullif not defined (or no file has been chosen in the multipart form)
-
getSize
long getSize()Return the size of the file in bytes.- 返回:
- the size of the file, or 0 if empty
-
getName
String getName()Return the name of the parameter in the multipart form. -
getOriginalFilename
Return the original filename in the client's filesystem.This may contain path information depending on the browser used, but it typically will not with any other than Opera.
Note: Please keep in mind this filename is supplied by the client and should not be used blindly. In addition to not using the directory portion, the file name could also contain characters such as ".." and others that can be used maliciously. It is recommended to not use this filename directly. Preferably generate a unique one and save this one somewhere for reference, if necessary.
- 返回:
- the original filename, or the empty String if no file has been chosen
in the multipart form, or
nullif not defined or not available - 另请参阅:
-
transferTo
Transfer the received file to the given destination file.This may either move the file in the filesystem, copy the file in the filesystem, or save memory-held contents to the destination file. If the destination file already exists, it will be deleted first.
If the target file has been moved in the filesystem, this operation cannot be invoked again afterwards. Therefore, call this method just once in order to work with any storage mechanism.
NOTE: Depending on the underlying provider, temporary storage may be container-dependent, including the base directory for relative destinations specified here (e.g. with Servlet multipart handling). For absolute destinations, the target file may get renamed/moved from its temporary location or newly copied, even if a temporary copy already exists.
- 参数:
dest- the destination file (typically absolute)- 抛出:
IOException- in case of reading or writing errorsIllegalStateException- if the file has already been moved in the filesystem and is not available anymore for another transfer- 另请参阅:
-
isEmpty
boolean isEmpty()Return whether the uploaded file is empty, that is, either no file has been chosen in the multipart form or the chosen file has no content. -
getBytes
Returns the contents of the file item as an array of bytes.- 抛出:
IOException- If any IO exception occurred- 从以下版本开始:
- 2.3.3
-
getOriginalResource
Object getOriginalResource()Get original resource- 返回:
- Original resource
- 从以下版本开始:
- 2.3.3
-
delete
Deletes the underlying storage for a file item, including deleting any associated temporary disk file.- 指定者:
delete在接口中Multipart- 抛出:
IOException- if an error occurs.- 从以下版本开始:
- 2.3.3
-
getResource
default cn.taketoday.core.io.Resource getResource()Return a Resource representation of this MultipartFile. This can be used as input to theRestTemplateor theWebClientto expose content length and the filename along with the InputStream.- 返回:
- this MultipartFile adapted to the Resource contract
- 从以下版本开始:
- 4.0
-
transferTo
Transfer the received file to the given destination file.The default implementation simply copies the file input stream.
- 抛出:
IOExceptionIllegalStateException- 从以下版本开始:
- 4.0
- 另请参阅:
-
InputStreamSource.getInputStream()transferTo(File)
-