Class Blobs

java.lang.Object
org.nuxeo.ecm.core.api.Blobs

public class Blobs extends Object
This class consists exclusively of static methods that operate on Blobs.
  • Method Details

    • createBlob

      public static Blob createBlob(File file) throws IOException
      Creates a Blob backed by the given File.
      Parameters:
      file - file
      Throws:
      IOException
    • createBlob

      public static Blob createBlob(File file, String mimeType) throws IOException
      Creates a Blob backed by the given File.
      Parameters:
      file - file
      mimeType - the MIME type
      Throws:
      IOException
    • createBlob

      public static Blob createBlob(File file, String mimeType, String encoding) throws IOException
      Creates a Blob backed by the given File.
      Parameters:
      file - file
      mimeType - the MIME type
      encoding - the encoding
      Throws:
      IOException
    • createBlob

      public static Blob createBlob(File file, String mimeType, String encoding, String filename) throws IOException
      Creates a Blob backed by the given File.
      Parameters:
      file - file
      mimeType - the MIME type
      encoding - the encoding
      filename - the blob filename
      Throws:
      IOException
    • createBlobWithExtension

      public static Blob createBlobWithExtension(String ext) throws IOException
      Creates a Blob backed by an empty temporary File with the given extension.
      Parameters:
      ext - the extension
      Throws:
      IOException
    • createBlob

      public static Blob createBlob(InputStream in) throws IOException
      Creates a Blob from an InputStream, by saving it to a temporary file.

      The input stream is closed.

      Parameters:
      in - the input stream, which is closed after use
      Throws:
      IOException
    • createBlob

      public static Blob createBlob(InputStream in, String mimeType) throws IOException
      Creates a Blob from an InputStream, by saving it to a temporary file.

      The input stream is closed.

      Parameters:
      in - the input stream, which is closed after use
      mimeType - the MIME type
      Throws:
      IOException
    • createBlob

      public static Blob createBlob(InputStream in, String mimeType, String encoding) throws IOException
      Creates a Blob from an InputStream, by saving it to a temporary file.

      The input stream is closed.

      Parameters:
      in - the input stream, which is closed after use
      mimeType - the MIME type
      encoding - the encoding
      Throws:
      IOException
    • createBlob

      public static Blob createBlob(InputStream in, String mimeType, String encoding, File tmpDir) throws IOException
      Creates a Blob from an InputStream, by saving it to a temporary file.

      The input stream is closed.

      Parameters:
      in - the input stream, which is closed after use
      mimeType - the MIME type
      encoding - the encoding
      tmpDir - the temporary directory for file creation
      Throws:
      IOException
    • createBlob

      public static Blob createBlob(byte[] bytes)
      Creates a Blob backed by the given bytes array.
      Parameters:
      bytes - the bytes array
    • createBlob

      public static Blob createBlob(byte[] bytes, String mimeType) throws IOException
      Creates a Blob backed by the given bytes array.
      Parameters:
      bytes - the bytes array
      mimeType - the MIME type
      Throws:
      IOException
    • createBlob

      public static Blob createBlob(byte[] bytes, String mimeType, String encoding) throws IOException
      Creates a Blob backed by the given bytes array.
      Parameters:
      bytes - the bytes array
      mimeType - the MIME type
      encoding - the encoding
      Throws:
      IOException
    • createBlob

      public static Blob createBlob(String string)
      Creates a Blob backed by the given string, with MIME type "text/plain" and encoding "UTF-8".
      Parameters:
      string - the string
    • createBlob

      public static Blob createBlob(String string, String mimeType)
      Creates a Blob backed by the given string, with encoding "UTF-8".
      Parameters:
      string - the string
      mimeType - the MIME type
    • createBlob

      public static Blob createBlob(String string, String mimeType, String encoding)
      Creates a Blob backed by the given string.
      Parameters:
      string - the string
      mimeType - the MIME type
      encoding - the encoding
    • createBlob

      public static Blob createBlob(String string, String mimeType, String encoding, String filename)
      Creates a Blob backed by the given string.
      Parameters:
      string - the string
      mimeType - the MIME type
      encoding - the encoding
      filename - the blob filename
    • createJSONBlob

      public static Blob createJSONBlob(String json)
      Create a Blob backed by the given JSON string.
      Parameters:
      json - the JSON string
      Since:
      9.2
    • createJSONBlobFromValue

      public static Blob createJSONBlobFromValue(Object value) throws IOException
      Create a Blob backed by the JSON for an arbitrary value.

      The value's internal classes may be annotated with Jackson 2 annotations.

      Parameters:
      value - the value
      Throws:
      IOException
      Since:
      9.2