Class FilesystemBlobProvider

java.lang.Object
org.nuxeo.ecm.core.blob.AbstractBlobProvider
org.nuxeo.ecm.core.blob.FilesystemBlobProvider
All Implemented Interfaces:
BlobProvider

public class FilesystemBlobProvider extends AbstractBlobProvider
Blob provider that can reference files on the filesystem.

This blob provider MUST be configured with a "root" property that specifies the minimum root path for all files:

 
 <blobprovider name="myfsblobprovider">
   <class>org.nuxeo.ecm.core.blob.FilesystemBlobProvider</class>
   <property name="root">/base/directory/for/files</property>
 </blobprovider>
 
 

A root of / may be used to allow any path.

Blobs are constructed through createBlob(org.nuxeo.ecm.core.blob.BlobInfo). The constructed blob's key, which will be stored in the document database, contains a path relative to the root.

Since:
7.10
  • Field Details

  • Constructor Details

    • FilesystemBlobProvider

      public FilesystemBlobProvider()
  • Method Details

    • initialize

      public void initialize(String blobProviderId, Map<String,String> properties) throws IOException
      Description copied from interface: BlobProvider
      Initializes the blob provider.
      Specified by:
      initialize in interface BlobProvider
      Overrides:
      initialize in class AbstractBlobProvider
      Parameters:
      blobProviderId - the blob provider id for this binary manager
      properties - initialization properties
      Throws:
      IOException
    • close

      public void close()
      Description copied from interface: BlobProvider
      Closes this blob provider and releases resources that may be held by it.
    • readBlob

      public Blob readBlob(BlobInfo blobInfo) throws IOException
      Description copied from interface: BlobProvider
      Reads a Blob from storage.
      Parameters:
      blobInfo - the blob information
      Returns:
      the blob
      Throws:
      IOException
    • stripBlobKeyPrefix

      protected String stripBlobKeyPrefix(String key)
    • getStream

      public InputStream getStream(ManagedBlob blob) throws IOException
      Description copied from interface: BlobProvider
      Gets an InputStream for the data of a managed blob.

      Like all InputStream, the result must be closed when done with it to avoid resource leaks.

      Parameters:
      blob - the managed blob
      Returns:
      the stream
      Throws:
      IOException
    • getFile

      public File getFile(ManagedBlob blob)
      Description copied from interface: BlobProvider
      Gets a File (if one exists) for the data of a managed blob.
      Parameters:
      blob - the managed blob
      Returns:
      the file, or null if no underlying file is available
    • supportsUserUpdate

      public boolean supportsUserUpdate()
      Description copied from interface: BlobProvider
      Checks if user update is supported.

      A user update refers to the fact that a blob from this provider may be overwritten with another blob, wherever the original blob may occur (usually in a document property).

      Specified by:
      supportsUserUpdate in interface BlobProvider
      Overrides:
      supportsUserUpdate in class AbstractBlobProvider
      Returns:
      true if user update is supported
    • supportsSync

      public boolean supportsSync()
      Description copied from interface: BlobProvider
      Checks if sync is supported.

      Sync refers to the fact that a blob from this provider may be synced with a remote system (like Nuxeo Drive) or with a process that updates things in the blob (like Binary Metadata, or WOPI).

      Returns:
      true if sync is supported
    • writeBlob

      public String writeBlob(Blob blob) throws IOException
      Description copied from interface: BlobProvider
      Writes a Blob to storage and returns information about it.

      Called to store a user-created blob.

      Parameters:
      blob - the blob
      Returns:
      the blob key
      Throws:
      IOException
    • createBlob

      public ManagedBlob createBlob(BlobInfo blobInfo) throws IOException
      Creates a filesystem blob with the given information.

      The passed BlobInfo contains information about the blob, and the key is a file path.

      Parameters:
      blobInfo - the blob info where the key is a file path
      Returns:
      the blob
      Throws:
      IOException