Interface DownloadService

  • All Known Implementing Classes:
    DownloadServiceImpl

    public interface DownloadService
    This service allows the download of blobs to a HTTP response.
    Since:
    7.3
    • Method Detail

      • storeBlobs

        String storeBlobs​(List<Blob> blobs)
        Stores the blobs for later download.
        Parameters:
        blobs - the list of blobs to store
        Returns:
        the store key used for retrieving the blobs (@see getDownloadUrl(String)
        Since:
        9.1
      • getFullDownloadUrl

        String getFullDownloadUrl​(DocumentModel doc,
                                  String xpath,
                                  Blob blob,
                                  String baseUrl)
        Gets the full download URL (after redirects if configured so) for the given blob.
        Parameters:
        doc - the document
        xpath - the blob's xpath or blobholder index, or null for default
        blob - the blob
        baseUrl - the base URL to use for Nuxeo downloads (if there is no redirect)
        Returns:
        the full URL (which may be to a redirected server)
        Since:
        11.1
        Implementation Requirements:
        Configuration to follow redirects is done through the org.nuxeo.download.url.follow.redirect configuration property.
      • getDownloadUrl

        String getDownloadUrl​(DocumentModel doc,
                              String xpath,
                              String filename)
        Gets the URL to use to download the blob at the given xpath in the given document.

        The URL is relative to the Nuxeo Web Application context.

        Returns something like nxfile/reponame/docuuid/blobholder:0/foo.jpg?changeToken=5-1

        Parameters:
        doc - the document
        xpath - the blob's xpath or blobholder index, or null for default
        filename - the blob's filename, or null for default
        Returns:
        the download URL with changeToken as query param for optimized http caching
      • getDownloadUrl

        String getDownloadUrl​(String repositoryName,
                              String docId,
                              String xpath,
                              String filename,
                              String changeToken)
        Gets the URL to use to download the blob at the given xpath in the given document.

        The URL is relative to the Nuxeo Web Application context.

        Returns something like nxfile/reponame/docuuid/blobholder:0/foo.jpg?changeToken=5-1

        Parameters:
        repositoryName - the document repository
        docId - the document id
        xpath - the blob's xpath or blobholder index, or null for default
        filename - the blob's filename, or null for default
        changeToken - the doc changeToken which will be appended as a query parameter for optimized http caching.
        Returns:
        the download URL
        Since:
        10.3
      • getDownloadUrl

        String getDownloadUrl​(String repositoryName,
                              String docId,
                              String xpath,
                              String filename)
        Gets the URL to use to download the blob at the given xpath in the given document.

        The URL is relative to the Nuxeo Web Application context.

        Returns something like nxfile/reponame/docuuid/blobholder:0/foo.jpg

        Parameters:
        repositoryName - the document repository
        docId - the document id
        xpath - the blob's xpath or blobholder index, or null for default
        filename - the blob's filename, or null for default
        Returns:
        the download URL
      • getDownloadUrl

        String getDownloadUrl​(String storeKey)
        Gets the URL to use to download the blobs identified by a storage key.

        The URL is relative to the Nuxeo Web Application context.

        Returns something like nxbigblob/key

        Parameters:
        storeKey - The key of stored blobs to download
        Returns:
        the download URL
        Since:
        9.1
      • handleDownload

        void handleDownload​(javax.servlet.http.HttpServletRequest req,
                            javax.servlet.http.HttpServletResponse resp,
                            String baseUrl,
                            String path)
                     throws IOException
        Handles the download of a document.
        Parameters:
        req - the request
        resp - the response
        baseUrl - the request baseUrl
        path - the request path, without the context
        Throws:
        IOException
        Since:
        9.1
      • downloadBlobStatus

        @Deprecated
        void downloadBlobStatus​(javax.servlet.http.HttpServletRequest request,
                                javax.servlet.http.HttpServletResponse response,
                                String storeKey,
                                String reason)
                         throws IOException
        Deprecated.
        since 10.3, use the @async operation adapter instead.
        Triggers a AsyncBlob download which gives information about an asynchronous blob.
        Parameters:
        storeKey - the stored blobs key
        reason - the download reason
        Throws:
        IOException
        Since:
        9.3
      • downloadBlob

        void downloadBlob​(javax.servlet.http.HttpServletRequest request,
                          javax.servlet.http.HttpServletResponse response,
                          String storeKey,
                          String reason)
                   throws IOException
        Triggers a blobs download. Once the temporary blobs are transfered from the store, they are automatically deleted. The returned HTTP Status Code is 200 if the blob is ready or 202 if it is still being processed.
        Parameters:
        storeKey - the stored blobs key
        reason - the download reason
        Throws:
        IOException
        Since:
        9.1
      • downloadBlob

        @Deprecated
        void downloadBlob​(javax.servlet.http.HttpServletRequest request,
                          javax.servlet.http.HttpServletResponse response,
                          DocumentModel doc,
                          String xpath,
                          Blob blob,
                          String filename,
                          String reason)
                   throws IOException
        Deprecated.
        since 11.1, use downloadBlob(DownloadContext) instead
        Triggers a blob download.
        Parameters:
        doc - the document, if available
        xpath - the blob's xpath or blobholder index, if available
        blob - the blob, if already fetched
        filename - the filename to use
        reason - the download reason
        Throws:
        IOException
      • downloadBlob

        @Deprecated
        void downloadBlob​(javax.servlet.http.HttpServletRequest request,
                          javax.servlet.http.HttpServletResponse response,
                          DocumentModel doc,
                          String xpath,
                          Blob blob,
                          String filename,
                          String reason,
                          Map<String,​Serializable> extendedInfos)
                   throws IOException
        Deprecated.
        since 11.1, use downloadBlob(DownloadContext) instead
        Triggers a blob download.
        Parameters:
        doc - the document, if available
        xpath - the blob's xpath or blobholder index, if available
        blob - the blob, if already fetched
        filename - the filename to use
        reason - the download reason
        extendedInfos - an optional map of extended informations to log
        Throws:
        IOException
      • downloadBlob

        @Deprecated
        void downloadBlob​(javax.servlet.http.HttpServletRequest request,
                          javax.servlet.http.HttpServletResponse response,
                          DocumentModel doc,
                          String xpath,
                          Blob blob,
                          String filename,
                          String reason,
                          Map<String,​Serializable> extendedInfos,
                          Boolean inline)
                   throws IOException
        Deprecated.
        since 11.1, use downloadBlob(DownloadContext) instead
        Triggers a blob download.
        Parameters:
        doc - the document, if available
        xpath - the blob's xpath or blobholder index, if available
        blob - the blob, if already fetched
        filename - the filename to use
        reason - the download reason
        extendedInfos - an optional map of extended informations to log
        inline - if not null, force the inline flag for content-disposition
        Throws:
        IOException
      • downloadBlob

        @Deprecated
        void downloadBlob​(javax.servlet.http.HttpServletRequest request,
                          javax.servlet.http.HttpServletResponse response,
                          DocumentModel doc,
                          String xpath,
                          Blob blob,
                          String filename,
                          String reason,
                          Map<String,​Serializable> extendedInfos,
                          Boolean inline,
                          Consumer<ByteRange> blobTransferer)
                   throws IOException
        Deprecated.
        since 11.1, use downloadBlob(DownloadContext) instead
        Triggers a blob download.
        Parameters:
        doc - the document, if available
        xpath - the blob's xpath or blobholder index, if available
        blob - the blob, if already fetched
        filename - the filename to use
        reason - the download reason
        extendedInfos - an optional map of extended informations to log
        inline - if not null, force the inline flag for content-disposition
        blobTransferer - the transferer of the actual blob
        Throws:
        IOException
        Since:
        7.10
      • transferBlobWithByteRange

        void transferBlobWithByteRange​(Blob blob,
                                       ByteRange byteRange,
                                       Supplier<OutputStream> outputStreamSupplier)
        Copies the blob stream at the given byte range into the supplied OutputStream.
        Parameters:
        blob - the blob
        byteRange - the byte range
        outputStreamSupplier - the OutputStream supplier
        Since:
        7.10
      • logDownload

        @Deprecated
        default void logDownload​(DocumentModel doc,
                                 String blobXPath,
                                 String filename,
                                 String reason,
                                 Map<String,​Serializable> extendedInfos)
        Deprecated.
        since 11.1, use the signature including the request
        Logs a download.
        Parameters:
        doc - the doc for which this download occurs, if available
        blobXPath - the blob's xpath or blobholder index, if available
        filename - the filename
        reason - the download reason
        extendedInfos - an optional map of extended informations to log
      • logDownload

        void logDownload​(javax.servlet.http.HttpServletRequest request,
                         DocumentModel doc,
                         String blobXPath,
                         String filename,
                         String reason,
                         Map<String,​Serializable> extendedInfos)
        Logs a download.
        Parameters:
        request - the HTTP request, if available
        doc - the doc for which this download occurs, if available
        blobXPath - the blob's xpath or blobholder index, if available
        filename - the filename
        reason - the download reason
        extendedInfos - an optional map of extended informations to log
        Since:
        11.1
      • resolveBlob

        Blob resolveBlob​(DocumentModel doc,
                         String xpath)
        Finds a document's blob given an xpath or blobholder index
        Parameters:
        doc - the document
        xpath - the xpath or blobholder index
        Returns:
        the blob, or null if not found
      • resolveBlob

        Blob resolveBlob​(DocumentModel doc)
        Finds a document's blob.
        Parameters:
        doc - the document
        Returns:
        the blob, or null if not available
        Since:
        9.3
      • checkPermission

        boolean checkPermission​(DocumentModel doc,
                                String xpath,
                                Blob blob,
                                String reason,
                                Map<String,​Serializable> extendedInfos)
        Checks whether the download of the blob is allowed.
        Parameters:
        doc - the doc for which this download occurs, if available
        xpath - the blob's xpath or blobholder index, if available
        blob - the blob
        reason - the download reason
        extendedInfos - an optional map of extended informations to log
        Returns:
        true if download is allowed
        Since:
        7.10