接口 MultipartFile

所有超级接口:
cn.taketoday.core.io.InputStreamSource, Multipart, Serializable
所有已知实现类:
AbstractMultipartFile, ServletPartMultipartFile

public interface MultipartFile extends Multipart, Serializable, cn.taketoday.core.io.InputStreamSource
A representation of an uploaded file received in a multipart request.

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
另请参阅:
  • 方法概要

    修饰符和类型
    方法
    说明
    void
    Deletes the underlying storage for a file item, including deleting any associated temporary disk file.
    byte[]
    Returns the contents of the file item as an array of bytes.
    Return the content type of the file.
    Return the name of the parameter in the multipart form.
    Return the original filename in the client's filesystem.
    Get original resource
    default cn.taketoday.core.io.Resource
    Return a Resource representation of this MultipartFile.
    long
    Return the size of the file in bytes.
    boolean
    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.
    void
    Transfer the received file to the given destination file.
    default void
    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

      @Nullable String getContentType()
      Return the content type of the file.
      返回:
      the content type, or null if 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.
      指定者:
      getName 在接口中 Multipart
      返回:
      the name of the parameter (never null or empty)
    • getOriginalFilename

      @Nullable String 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 null if not defined or not available
      另请参阅:
    • transferTo

      void transferTo(File dest) throws IOException, IllegalStateException
      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 errors
      IllegalStateException - 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

      byte[] getBytes() throws IOException
      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

      void delete() throws IOException
      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 the RestTemplate or the WebClient to expose content length and the filename along with the InputStream.
      返回:
      this MultipartFile adapted to the Resource contract
      从以下版本开始:
      4.0
    • transferTo

      default void transferTo(Path dest) throws IOException, IllegalStateException
      Transfer the received file to the given destination file.

      The default implementation simply copies the file input stream.

      抛出:
      IOException
      IllegalStateException
      从以下版本开始:
      4.0
      另请参阅: