Class FileAwareMultipartFile

  • All Implemented Interfaces:
    org.springframework.core.io.InputStreamSource, org.springframework.web.multipart.MultipartFile

    public class FileAwareMultipartFile
    extends Object
    implements org.springframework.web.multipart.MultipartFile
    The file aware multipart file.
    Author:
    Christian Bremer
    • Constructor Detail

      • FileAwareMultipartFile

        public FileAwareMultipartFile​(org.springframework.web.multipart.MultipartFile multipartFile)
                               throws IOException
        Instantiates a new file aware multipart file.
        Parameters:
        multipartFile - the multipart file
        Throws:
        IOException - the io exception
      • FileAwareMultipartFile

        public FileAwareMultipartFile​(org.springframework.web.multipart.MultipartFile multipartFile,
                                      String tmpDir)
                               throws IOException
        Instantiates a new file aware multipart file.
        Parameters:
        multipartFile - the multipart file
        tmpDir - the tmp dir
        Throws:
        IOException - the io exception
      • FileAwareMultipartFile

        public FileAwareMultipartFile​(org.springframework.web.multipart.MultipartFile multipartFile,
                                      File tmpDir)
                               throws IOException
        Instantiates a new file aware multipart file.
        Parameters:
        multipartFile - the multipart file
        tmpDir - the tmp dir
        Throws:
        IOException - the io exception
      • FileAwareMultipartFile

        public FileAwareMultipartFile​(InputStream inputStream,
                                      String parameterName,
                                      String originalFilename,
                                      String contentType)
                               throws IOException
        Instantiates a new File aware multipart file.
        Parameters:
        inputStream - the input stream
        parameterName - the parameter name
        originalFilename - the original filename
        contentType - the content type
        Throws:
        IOException - the io exception
      • FileAwareMultipartFile

        public FileAwareMultipartFile​(InputStream inputStream,
                                      String tmpDir,
                                      String parameterName,
                                      String originalFilename,
                                      String contentType)
                               throws IOException
        Instantiates a new File aware multipart file.
        Parameters:
        inputStream - the input stream
        tmpDir - the tmp dir
        parameterName - the parameter name
        originalFilename - the original filename
        contentType - the content type
        Throws:
        IOException - the io exception
      • FileAwareMultipartFile

        public FileAwareMultipartFile​(InputStream inputStream,
                                      File tmpDir,
                                      String parameterName,
                                      String originalFilename,
                                      String contentType)
                               throws IOException
        Instantiates a new File aware multipart file.
        Parameters:
        inputStream - the input stream
        tmpDir - the tmp dir
        parameterName - the parameter name
        originalFilename - the original filename
        contentType - the content type
        Throws:
        IOException - the io exception
      • FileAwareMultipartFile

        public FileAwareMultipartFile​(Path file,
                                      String parameterName,
                                      String originalFilename,
                                      String contentType)
        Instantiates a new File aware multipart file.
        Parameters:
        file - the file
        parameterName - the parameter name
        originalFilename - the original filename
        contentType - the content type
      • FileAwareMultipartFile

        public FileAwareMultipartFile​(File file,
                                      String parameterName,
                                      String originalFilename,
                                      String contentType)
        Instantiates a new File aware multipart file.
        Parameters:
        file - the file
        parameterName - the parameter name
        originalFilename - the original filename
        contentType - the content type
    • Method Detail

      • empty

        public static FileAwareMultipartFile empty()
        Empty file aware multipart file.
        Returns:
        the file aware multipart file
      • delete

        public static void delete​(org.springframework.web.multipart.MultipartFile multipartFile)
        Delete.
        Parameters:
        multipartFile - the multipart file
      • getName

        @NonNull
        public String getName()
        Specified by:
        getName in interface org.springframework.web.multipart.MultipartFile
      • getOriginalFilename

        public String getOriginalFilename()
        Specified by:
        getOriginalFilename in interface org.springframework.web.multipart.MultipartFile
      • getContentType

        public String getContentType()
        Specified by:
        getContentType in interface org.springframework.web.multipart.MultipartFile
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface org.springframework.web.multipart.MultipartFile
      • getSize

        public long getSize()
        Specified by:
        getSize in interface org.springframework.web.multipart.MultipartFile
      • getBytes

        @NonNull
        public byte[] getBytes()
                        throws IOException
        Specified by:
        getBytes in interface org.springframework.web.multipart.MultipartFile
        Throws:
        IOException
      • getInputStream

        @NonNull
        public InputStream getInputStream()
                                   throws IOException
        Specified by:
        getInputStream in interface org.springframework.core.io.InputStreamSource
        Specified by:
        getInputStream in interface org.springframework.web.multipart.MultipartFile
        Throws:
        IOException
      • getResource

        @NonNull
        public org.springframework.core.io.Resource getResource()
        Specified by:
        getResource in interface org.springframework.web.multipart.MultipartFile