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
Nested Classes Modifier and Type Interface Description static class
DownloadService.DownloadContext
Download context.
-
Field Summary
Fields Modifier and Type Field Description static String
BLOBHOLDER_0
static String
BLOBHOLDER_PREFIX
static String
EVENT_NAME
static String
EXTENDED_INFO_CLIENT_REASON
The extended info containing the client reason.static String
EXTENDED_INFO_RENDITION
The extended info containing the rendition name.static String
NXBIGBLOB
static String
NXBIGFILE
Deprecated.since 7.4, use nxfile insteadstatic String
NXBIGZIPFILE
Deprecated.since 9.1, use nxbigblob insteadstatic String
NXBLOBSTATUS
static String
NXDOWNLOADINFO
static String
NXFILE
static String
REQUEST_ATTR_DOWNLOAD_REASON
Internal request attribute recording the reason to use for the download.static String
REQUEST_ATTR_DOWNLOAD_RENDITION
Internal request attribute recording the rendition triggering the download.static String
REQUEST_HEADER_CLIENT_REASON
Public request header recording the client reason to use for the download.static String
REQUEST_QUERY_PARAM_CLIENT_REASON
Public request query parameter recording the client reason to use for the download.static String
TRANSIENT_STORE_PARAM_ERROR
The transient store parameter name for storing an error if any.static String
TRANSIENT_STORE_PARAM_PROGRESS
static String
TRANSIENT_STORE_STORE_NAME
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description boolean
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.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)
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
downloadBlob(DownloadService.DownloadContext context)
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.String
getDownloadUrl(String storeKey)
Gets the URL to use to download the blobs identified by a storage key.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.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.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.String
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 requestBlob
resolveBlob(DocumentModel doc)
Finds a document's blob.Blob
resolveBlob(DocumentModel doc, String xpath)
Finds a document's blob given an xpath or blobholder indexBlob
resolveBlobFromDownloadUrl(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)
.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 Detail
-
EVENT_NAME
static final String EVENT_NAME
- See Also:
- Constant Field Values
-
NXFILE
static final String NXFILE
- See Also:
- Constant Field Values
-
NXDOWNLOADINFO
static final String NXDOWNLOADINFO
- See Also:
- Constant Field Values
-
NXBLOBSTATUS
static final String NXBLOBSTATUS
- Since:
- 9.3
- See Also:
- Constant Field Values
-
NXBIGBLOB
static final String NXBIGBLOB
- See Also:
- Constant Field Values
-
NXBIGZIPFILE
@Deprecated static final String NXBIGZIPFILE
Deprecated.since 9.1, use nxbigblob instead- See Also:
- Constant Field Values
-
NXBIGFILE
@Deprecated static final String NXBIGFILE
Deprecated.since 7.4, use nxfile instead- See Also:
- Constant Field Values
-
BLOBHOLDER_PREFIX
static final String BLOBHOLDER_PREFIX
- See Also:
- Constant Field Values
-
BLOBHOLDER_0
static final String BLOBHOLDER_0
- See Also:
- Constant Field Values
-
TRANSIENT_STORE_PARAM_ERROR
static final String TRANSIENT_STORE_PARAM_ERROR
The transient store parameter name for storing an error if any. Stored entry must- See Also:
- Constant Field Values
-
TRANSIENT_STORE_PARAM_PROGRESS
static final String TRANSIENT_STORE_PARAM_PROGRESS
- See Also:
- Constant Field Values
-
TRANSIENT_STORE_STORE_NAME
static final String TRANSIENT_STORE_STORE_NAME
- See Also:
- Constant Field Values
-
EXTENDED_INFO_RENDITION
static final String EXTENDED_INFO_RENDITION
The extended info containing the rendition name.- Since:
- 11.1
- See Also:
- Constant Field Values
-
EXTENDED_INFO_CLIENT_REASON
static final String EXTENDED_INFO_CLIENT_REASON
The extended info containing the client reason.- Since:
- 2023.0
- See Also:
- Constant Field Values
-
REQUEST_ATTR_DOWNLOAD_REASON
static final String REQUEST_ATTR_DOWNLOAD_REASON
Internal request attribute recording the reason to use for the download.- Since:
- 11.1
- See Also:
- Constant Field Values
-
REQUEST_ATTR_DOWNLOAD_RENDITION
static final String REQUEST_ATTR_DOWNLOAD_RENDITION
Internal request attribute recording the rendition triggering the download.- Since:
- 11.1
- See Also:
- Constant Field Values
-
REQUEST_QUERY_PARAM_CLIENT_REASON
static final String REQUEST_QUERY_PARAM_CLIENT_REASON
Public request query parameter recording the client reason to use for the download.- Since:
- 2023.0
- See Also:
- Constant Field Values
-
REQUEST_HEADER_CLIENT_REASON
static final String REQUEST_HEADER_CLIENT_REASON
Public request header recording the client reason to use for the download.- Since:
- 2023.0
- See Also:
- Constant Field Values
-
-
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 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
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 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
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 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
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
-
resolveBlobFromDownloadUrl
Blob resolveBlobFromDownloadUrl(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)
.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 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 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 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 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 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 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
void downloadBlob(DownloadService.DownloadContext context) throws IOException
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
Blob resolveBlob(DocumentModel doc, String xpath)
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
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 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
-
-