Class GrailsByteArrayResource

  • All Implemented Interfaces:
    org.springframework.core.io.InputStreamSource, org.springframework.core.io.Resource

    public class GrailsByteArrayResource
    extends org.springframework.core.io.ByteArrayResource
    Hacky version of the ByteArrayResource that implements the getURL() method, required for the resource to work with Spring's ServletContextResource.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getFilename()  
      java.net.URL getURL()
      Overrides the default behaviour to generate a fake "file:" URL so that the resource can be used from a ServletContextResource.
      • Methods inherited from class org.springframework.core.io.ByteArrayResource

        contentLength, equals, exists, getByteArray, getDescription, getInputStream, hashCode
      • Methods inherited from class org.springframework.core.io.AbstractResource

        createRelative, getFile, getFileForLastModifiedCheck, getURI, isFile, isOpen, isReadable, lastModified, readableChannel, toString
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • GrailsByteArrayResource

        public GrailsByteArrayResource​(byte[] byteArray)
      • GrailsByteArrayResource

        public GrailsByteArrayResource​(byte[] byteArray,
                                       java.lang.String location)
    • Method Detail

      • getURL

        public java.net.URL getURL()
                            throws java.io.IOException
        Overrides the default behaviour to generate a fake "file:" URL so that the resource can be used from a ServletContextResource.
        Specified by:
        getURL in interface org.springframework.core.io.Resource
        Overrides:
        getURL in class org.springframework.core.io.AbstractResource
        Throws:
        java.io.IOException
      • getFilename

        public java.lang.String getFilename()
                                     throws java.lang.IllegalStateException
        Specified by:
        getFilename in interface org.springframework.core.io.Resource
        Overrides:
        getFilename in class org.springframework.core.io.AbstractResource
        Throws:
        java.lang.IllegalStateException