Class MultipartFileResource

java.lang.Object
org.springframework.core.io.AbstractResource
net.solarnetwork.web.support.MultipartFileResource
All Implemented Interfaces:
net.solarnetwork.io.TransferrableResource, org.springframework.core.io.InputStreamSource, org.springframework.core.io.Resource

public class MultipartFileResource extends org.springframework.core.io.AbstractResource implements org.springframework.core.io.Resource, net.solarnetwork.io.TransferrableResource
Resource that delegates operations to a MultipartFile.

This class also implements TransferrableResource so classes that receive this as a Resource can test for that API and efficiently move the temporary multipart file to some other location.

Since:
1.15
Version:
1.0
Author:
matt
  • Constructor Summary

    Constructors
    Constructor
    Description
    MultipartFileResource(org.springframework.web.multipart.MultipartFile multipart)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
     
     
     
    void
     

    Methods inherited from class org.springframework.core.io.AbstractResource

    contentLength, createRelative, equals, exists, getFile, getFileForLastModifiedCheck, getURI, getURL, hashCode, isOpen, isReadable, lastModified, toString

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.springframework.core.io.Resource

    contentLength, createRelative, exists, getFile, getURI, getURL, isOpen, isReadable, lastModified
  • Constructor Details

    • MultipartFileResource

      public MultipartFileResource(org.springframework.web.multipart.MultipartFile multipart)
      Constructor.
      Parameters:
      multipart - the multipart file to delegate to
      Throws:
      IllegalArgumentException - if multipart is null
  • Method Details

    • getInputStream

      public InputStream getInputStream() throws IOException
      Specified by:
      getInputStream in interface org.springframework.core.io.InputStreamSource
      Throws:
      IOException
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in interface org.springframework.core.io.Resource
    • getFilename

      public String getFilename()
      Specified by:
      getFilename in interface org.springframework.core.io.Resource
      Overrides:
      getFilename in class org.springframework.core.io.AbstractResource
    • transferTo

      public void transferTo(File dest) throws IOException, IllegalStateException
      Specified by:
      transferTo in interface net.solarnetwork.io.TransferrableResource
      Throws:
      IOException
      IllegalStateException