类 MockMultipartFile

java.lang.Object
cn.taketoday.mock.web.MockMultipartFile
所有已实现的接口:
cn.taketoday.core.io.InputStreamSource, cn.taketoday.util.function.ThrowingConsumer<OutputStream>, cn.taketoday.web.multipart.Multipart, cn.taketoday.web.multipart.MultipartFile, Consumer<OutputStream>

public class MockMultipartFile extends Object implements cn.taketoday.web.multipart.MultipartFile
Mock implementation of the MultipartFile interface.

Useful in conjunction with a MockMultipartHttpServletRequest for testing application controllers that access multipart uploads.

从以下版本开始:
4.0
作者:
Juergen Hoeller, Eric Crampton, Harry Yang
另请参阅:
  • 字段详细资料

    • serialVersionUID

      private static final long serialVersionUID
      另请参阅:
    • name

      private final String name
    • originalFilename

      private final String originalFilename
    • contentType

      @Nullable private final String contentType
    • content

      private final byte[] content
    • headers

      protected cn.taketoday.http.HttpHeaders headers
  • 构造器详细资料

    • MockMultipartFile

      public MockMultipartFile(String name, @Nullable byte[] content)
      Create a new MockMultipartFile with the given content.
      参数:
      name - the name of the file
      content - the content of the file
    • MockMultipartFile

      public MockMultipartFile(String name, InputStream contentStream) throws IOException
      Create a new MockMultipartFile with the given content.
      参数:
      name - the name of the file
      contentStream - the content of the file as stream
      抛出:
      IOException - if reading from the stream failed
    • MockMultipartFile

      public MockMultipartFile(String name, @Nullable String originalFilename, @Nullable String contentType, @Nullable byte[] content)
      Create a new MockMultipartFile with the given content.
      参数:
      name - the name of the file
      originalFilename - the original filename (as on the client's machine)
      contentType - the content type (if known)
      content - the content of the file
    • MockMultipartFile

      public MockMultipartFile(String name, @Nullable String originalFilename, @Nullable String contentType, InputStream contentStream) throws IOException
      Create a new MockMultipartFile with the given content.
      参数:
      name - the name of the file
      originalFilename - the original filename (as on the client's machine)
      contentType - the content type (if known)
      contentStream - the content of the file as stream
      抛出:
      IOException - if reading from the stream failed
  • 方法详细资料

    • getName

      public String getName()
      指定者:
      getName 在接口中 cn.taketoday.web.multipart.Multipart
      指定者:
      getName 在接口中 cn.taketoday.web.multipart.MultipartFile
    • getValue

      public String getValue()
      指定者:
      getValue 在接口中 cn.taketoday.web.multipart.Multipart
    • isFormField

      public boolean isFormField()
      指定者:
      isFormField 在接口中 cn.taketoday.web.multipart.Multipart
    • setHeaders

      public void setHeaders(cn.taketoday.http.HttpHeaders headers)
    • getHeaders

      public cn.taketoday.http.HttpHeaders getHeaders()
      指定者:
      getHeaders 在接口中 cn.taketoday.web.multipart.Multipart
    • createHttpHeaders

      protected cn.taketoday.http.DefaultHttpHeaders createHttpHeaders()
    • getOriginalFilename

      public String getOriginalFilename()
      指定者:
      getOriginalFilename 在接口中 cn.taketoday.web.multipart.MultipartFile
    • getContentType

      @Nullable public String getContentType()
      指定者:
      getContentType 在接口中 cn.taketoday.web.multipart.Multipart
      指定者:
      getContentType 在接口中 cn.taketoday.web.multipart.MultipartFile
    • isEmpty

      public boolean isEmpty()
      指定者:
      isEmpty 在接口中 cn.taketoday.web.multipart.MultipartFile
    • getSize

      public long getSize()
      指定者:
      getSize 在接口中 cn.taketoday.web.multipart.MultipartFile
    • getBytes

      public byte[] getBytes() throws IOException
      指定者:
      getBytes 在接口中 cn.taketoday.web.multipart.Multipart
      指定者:
      getBytes 在接口中 cn.taketoday.web.multipart.MultipartFile
      抛出:
      IOException
    • getOriginalResource

      public Object getOriginalResource()
      指定者:
      getOriginalResource 在接口中 cn.taketoday.web.multipart.MultipartFile
    • delete

      public void delete() throws IOException
      指定者:
      delete 在接口中 cn.taketoday.web.multipart.Multipart
      指定者:
      delete 在接口中 cn.taketoday.web.multipart.MultipartFile
      抛出:
      IOException
    • getInputStream

      public InputStream getInputStream() throws IOException
      指定者:
      getInputStream 在接口中 cn.taketoday.core.io.InputStreamSource
      抛出:
      IOException
    • transferTo

      public void transferTo(File dest) throws IOException, IllegalStateException
      指定者:
      transferTo 在接口中 cn.taketoday.web.multipart.MultipartFile
      抛出:
      IOException
      IllegalStateException