Package org.nuxeo.ecm.core.io.download
Interface DownloadService
- All Known Implementing Classes:
DownloadServiceImpl
public interface DownloadService
This service allows the download of blobs to a HTTP response.
- Since:
- 7.3
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
Download context. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
The extended info containing the client reason.static final String
The extended info containing the rendition name.static final String
static final String
static final String
static final String
static final String
Internal request attribute recording the reason to use for the download.static final String
Internal request attribute recording the rendition triggering the download.static final String
Public request header recording the client reason to use for the download.static final String
Public request query parameter recording the client reason to use for the download.static final String
The transient store parameter name for storing an error if any.static final String
static final String
-
Method Summary
Modifier and TypeMethodDescriptionboolean
checkPermission
(DocumentModel doc, String xpath, Blob blob, String reason, Map<String, Serializable> extendedInfos) Checks whether the download of the blob is allowed.void
downloadBlob
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String storeKey, String reason) Triggers a blobs download.void
downloadBlob
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, DocumentModel doc, String xpath, Blob blob, String filename, String reason) 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) Deprecated.since 11.1, usedownloadBlob(DownloadContext)
insteadvoid
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) Deprecated.since 11.1, usedownloadBlob(DownloadContext)
insteadvoid
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) Deprecated.since 11.1, usedownloadBlob(DownloadContext)
insteadvoid
Triggers a blob download.void
downloadBlobStatus
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String storeKey, String reason) Deprecated.since 10.3, use the @async operation adapter instead.getDownloadUrl
(String storeKey) Gets the URL to use to download the blobs identified by a storage key.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.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.getDownloadUrl
(DocumentModel doc, String xpath, String filename) Gets the URL to use to download the blob at the given xpath in the given document.getFullDownloadUrl
(DocumentModel doc, String xpath, Blob blob, String baseUrl) Gets the full download URL (after redirects if configured so) for the given blob.void
handleDownload
(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, String baseUrl, String path) Handles the download of a document.void
logDownload
(javax.servlet.http.HttpServletRequest request, DocumentModel doc, String blobXPath, String filename, String reason, Map<String, Serializable> extendedInfos) Logs a download.default void
logDownload
(DocumentModel doc, String blobXPath, String filename, String reason, Map<String, Serializable> extendedInfos) Deprecated.since 11.1, use the signature including the requestresolveBlob
(DocumentModel doc) Finds a document's blob.resolveBlob
(DocumentModel doc, String xpath) Finds a document's blob given an xpath or blobholder indexresolveBlobFromDownloadUrl
(String downloadURL) Finds a document's blob given the download URL returned bygetDownloadUrl(org.nuxeo.ecm.core.api.DocumentModel, java.lang.String, java.lang.String)
.storeBlobs
(List<Blob> blobs) Stores the blobs for later download.void
transferBlobWithByteRange
(Blob blob, ByteRange byteRange, Supplier<OutputStream> outputStreamSupplier) Copies the blob stream at the given byte range into the suppliedOutputStream
.
-
Field Details
-
EVENT_NAME
- See Also:
-
NXFILE
- See Also:
-
NXDOWNLOADINFO
- See Also:
-
NXBLOBSTATUS
- Since:
- 9.3
- See Also:
-
NXBIGBLOB
- See Also:
-
BLOBHOLDER_PREFIX
- See Also:
-
BLOBHOLDER_0
- See Also:
-
TRANSIENT_STORE_PARAM_ERROR
The transient store parameter name for storing an error if any. Stored entry must- See Also:
-
TRANSIENT_STORE_PARAM_PROGRESS
- See Also:
-
TRANSIENT_STORE_STORE_NAME
- See Also:
-
EXTENDED_INFO_RENDITION
The extended info containing the rendition name.- Since:
- 11.1
- See Also:
-
EXTENDED_INFO_CLIENT_REASON
The extended info containing the client reason.- Since:
- 2023.0
- See Also:
-
REQUEST_ATTR_DOWNLOAD_REASON
Internal request attribute recording the reason to use for the download.- Since:
- 11.1
- See Also:
-
REQUEST_ATTR_DOWNLOAD_RENDITION
Internal request attribute recording the rendition triggering the download.- Since:
- 11.1
- See Also:
-
REQUEST_QUERY_PARAM_CLIENT_REASON
Public request query parameter recording the client reason to use for the download.- Since:
- 2023.0
- See Also:
-
REQUEST_HEADER_CLIENT_REASON
Public request header recording the client reason to use for the download.- Since:
- 2023.0
- See Also:
-
-
Method Details
-
storeBlobs
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
Gets the full download URL (after redirects if configured so) for the given blob.- Parameters:
doc
- the documentxpath
- the blob's xpath or blobholder index, ornull
for defaultblob
- the blobbaseUrl
- 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
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 documentxpath
- the blob's xpath or blobholder index, ornull
for defaultfilename
- the blob's filename, ornull
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 repositorydocId
- the document idxpath
- the blob's xpath or blobholder index, ornull
for defaultfilename
- the blob's filename, ornull
for defaultchangeToken
- the doc changeToken which will be appended as a query parameter for optimized http caching.- Returns:
- the download URL
- Since:
- 10.3
-
getDownloadUrl
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 repositorydocId
- the document idxpath
- the blob's xpath or blobholder index, ornull
for defaultfilename
- the blob's filename, ornull
for default- Returns:
- the download URL
-
getDownloadUrl
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
-
resolveBlobFromDownloadUrl
Finds a document's blob given the download URL returned bygetDownloadUrl(org.nuxeo.ecm.core.api.DocumentModel, java.lang.String, java.lang.String)
.The permissions are check whether the user can download the blob or not.
- Parameters:
downloadURL
- the URL to use to download the blob- Returns:
- the blob, or
null
if not found or if the user has no permission to download it - 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 requestresp
- the responsebaseUrl
- the request baseUrlpath
- 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 aAsyncBlob
download which gives information about an asynchronous blob.- Parameters:
storeKey
- the stored blobs keyreason
- 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 keyreason
- 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, usedownloadBlob(DownloadContext)
insteadTriggers a blob download.- Parameters:
doc
- the document, if availablexpath
- the blob's xpath or blobholder index, if availableblob
- the blob, if already fetchedfilename
- the filename to usereason
- 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 IOExceptionDeprecated.since 11.1, usedownloadBlob(DownloadContext)
insteadTriggers a blob download.- Parameters:
doc
- the document, if availablexpath
- the blob's xpath or blobholder index, if availableblob
- the blob, if already fetchedfilename
- the filename to usereason
- the download reasonextendedInfos
- 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 IOExceptionDeprecated.since 11.1, usedownloadBlob(DownloadContext)
insteadTriggers a blob download.- Parameters:
doc
- the document, if availablexpath
- the blob's xpath or blobholder index, if availableblob
- the blob, if already fetchedfilename
- the filename to usereason
- the download reasonextendedInfos
- an optional map of extended informations to loginline
- 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 IOExceptionDeprecated.since 11.1, usedownloadBlob(DownloadContext)
insteadTriggers a blob download.- Parameters:
doc
- the document, if availablexpath
- the blob's xpath or blobholder index, if availableblob
- the blob, if already fetchedfilename
- the filename to usereason
- the download reasonextendedInfos
- an optional map of extended informations to loginline
- if not null, force the inline flag for content-dispositionblobTransferer
- the transferer of the actual blob- Throws:
IOException
- Since:
- 7.10
-
downloadBlob
Triggers a blob download.- Parameters:
context
- the download context- Throws:
IOException
- Since:
- 11.1
-
transferBlobWithByteRange
void transferBlobWithByteRange(Blob blob, ByteRange byteRange, Supplier<OutputStream> outputStreamSupplier) Copies the blob stream at the given byte range into the suppliedOutputStream
.- Parameters:
blob
- the blobbyteRange
- the byte rangeoutputStreamSupplier
- theOutputStream
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 requestLogs a download.- Parameters:
doc
- the doc for which this download occurs, if availableblobXPath
- the blob's xpath or blobholder index, if availablefilename
- the filenamereason
- the download reasonextendedInfos
- 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 availabledoc
- the doc for which this download occurs, if availableblobXPath
- the blob's xpath or blobholder index, if availablefilename
- the filenamereason
- the download reasonextendedInfos
- an optional map of extended informations to log- Since:
- 11.1
-
resolveBlob
Finds a document's blob given an xpath or blobholder index- Parameters:
doc
- the documentxpath
- the xpath or blobholder index- Returns:
- the blob, or
null
if not found
-
resolveBlob
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 availablexpath
- the blob's xpath or blobholder index, if availableblob
- the blobreason
- the download reasonextendedInfos
- an optional map of extended informations to log- Returns:
true
if download is allowed- Since:
- 7.10
-
downloadBlob(DownloadContext)
instead