public class TusFileUploadService extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
TUS_API_VERSION |
| Constructor and Description |
|---|
TusFileUploadService() |
| Modifier and Type | Method and Description |
|---|---|
TusFileUploadService |
addTusExtension(TusExtension feature)
Add a custom (application-specific) extension that implements the
TusExtension
interface. |
void |
cleanup()
This method should be invoked periodically.
|
void |
deleteUpload(String uploadURI)
Method to delete an upload associated with the given upload URL.
|
void |
deleteUpload(String uploadURI,
String ownerKey)
Method to delete an upload associated with the given upload URL.
|
TusFileUploadService |
disableTusExtension(String extensionName)
Disable the TusExtension for which the getName() method matches the provided string.
|
protected void |
executeProcessingByFeatures(HttpMethod method,
TusServletRequest servletRequest,
TusServletResponse servletResponse,
String ownerKey) |
Set<String> |
getEnabledFeatures()
Get the set of enabled Tus extensions
|
Set<HttpMethod> |
getSupportedHttpMethods()
Get all HTTP methods that are supported by this TusUploadService based on the enabled and/or disabled
tus extensions
|
InputStream |
getUploadedBytes(String uploadURI)
Method to retrieve the bytes that were uploaded to a specific upload URI
|
InputStream |
getUploadedBytes(String uploadURI,
String ownerKey)
Method to retrieve the bytes that were uploaded to a specific upload URI
|
UploadInfo |
getUploadInfo(String uploadURI)
Get the information on the upload corresponding to the given upload URI
|
UploadInfo |
getUploadInfo(String uploadURI,
String ownerKey)
Get the information on the upload corresponding to the given upload URI
|
protected void |
initFeatures() |
void |
process(javax.servlet.http.HttpServletRequest servletRequest,
javax.servlet.http.HttpServletResponse servletResponse)
Process a tus upload request.
|
void |
process(javax.servlet.http.HttpServletRequest servletRequest,
javax.servlet.http.HttpServletResponse servletResponse,
String ownerKey)
Process a tus upload request that belongs to a specific owner.
|
protected void |
processLockedRequest(HttpMethod method,
TusServletRequest request,
TusServletResponse response,
String ownerKey) |
protected void |
processTusException(HttpMethod method,
TusServletRequest request,
TusServletResponse response,
String ownerKey,
TusException exception) |
protected void |
validateRequest(HttpMethod method,
javax.servlet.http.HttpServletRequest servletRequest,
String ownerKey) |
TusFileUploadService |
withChunkedTransferDecoding(boolean isEnabled)
Instruct this service to (not) decode any requests with Transfer-Encoding value "chunked".
|
TusFileUploadService |
withDownloadFeature()
Enable the unofficial `download` extension that also allows you to download uploaded bytes.
|
TusFileUploadService |
withMaxUploadSize(Long maxUploadSize)
Specify the maximum number of bytes that can be uploaded per upload.
|
TusFileUploadService |
withStoragePath(String storagePath)
If you're using the default file system-based storage service, you can use this method to
specify the path where to store the uploaded bytes and upload information.
|
TusFileUploadService |
withThreadLocalCache(boolean isEnabled)
Enable or disable a thread-local based cache of upload data.
|
TusFileUploadService |
withUploadExpirationPeriod(Long expirationPeriod)
You can set the number of milliseconds after which an upload is considered as expired and available for cleanup.
|
TusFileUploadService |
withUploadIdFactory(UploadIdFactory uploadIdFactory)
Provide a custom
UploadIdFactory implementation that should be used to generate identifiers for
the different uploads. |
TusFileUploadService |
withUploadLockingService(UploadLockingService uploadLockingService)
Provide a custom
UploadLockingService implementation that should be used when processing uploads. |
TusFileUploadService |
withUploadStorageService(UploadStorageService uploadStorageService)
Provide a custom
UploadStorageService implementation that should be used to store uploaded bytes and
metadata (UploadInfo). |
TusFileUploadService |
withUploadURI(String uploadURI)
Set the URI under which the main tus upload endpoint is hosted.
|
public static final String TUS_API_VERSION
protected void initFeatures()
public TusFileUploadService withUploadURI(String uploadURI)
uploadURI - The URI of the main tus upload endpointpublic TusFileUploadService withMaxUploadSize(Long maxUploadSize)
maxUploadSize - The maximum upload length that is allowedpublic TusFileUploadService withUploadIdFactory(UploadIdFactory uploadIdFactory)
UploadIdFactory implementation that should be used to generate identifiers for
the different uploads. Example implementation are UUIDUploadIdFactory and
TimeBasedUploadIdFactory.uploadIdFactory - The custom UploadIdFactory implementationpublic TusFileUploadService withUploadStorageService(UploadStorageService uploadStorageService)
UploadStorageService implementation that should be used to store uploaded bytes and
metadata (UploadInfo).uploadStorageService - The custom UploadStorageService implementationpublic TusFileUploadService withUploadLockingService(UploadLockingService uploadLockingService)
UploadLockingService implementation that should be used when processing uploads.
The upload locking service is responsible for locking an upload that is being processed so that it cannot
be corrupted by simultaneous or delayed requests.uploadLockingService - The UploadLockingService implementation to usepublic TusFileUploadService withStoragePath(String storagePath)
storagePath - The file system path where uploads can be stored (temporarily)public TusFileUploadService withThreadLocalCache(boolean isEnabled)
isEnabled - True if the cache should be enabled, false otherwisepublic TusFileUploadService withChunkedTransferDecoding(boolean isEnabled)
isEnabled - True if chunked requests should be decoded, false otherwise.public TusFileUploadService withUploadExpirationPeriod(Long expirationPeriod)
expirationPeriod - The number of milliseconds after which an upload expires and can be removedpublic TusFileUploadService withDownloadFeature()
public TusFileUploadService addTusExtension(TusExtension feature)
TusExtension
interface. For example you can add your own extension that checks authentication and authorization policies
within your application for the user doing the upload.feature - The custom extension implementationpublic TusFileUploadService disableTusExtension(String extensionName)
extensionName - The name of the extension to disablepublic Set<HttpMethod> getSupportedHttpMethods()
public Set<String> getEnabledFeatures()
public void process(javax.servlet.http.HttpServletRequest servletRequest,
javax.servlet.http.HttpServletResponse servletResponse)
throws IOException
servletRequest - The HttpServletRequest of the requestservletResponse - The HttpServletResponse of the requestIOException - When saving bytes or information of this requests failspublic void process(javax.servlet.http.HttpServletRequest servletRequest,
javax.servlet.http.HttpServletResponse servletResponse,
String ownerKey)
throws IOException
servletRequest - The HttpServletRequest of the requestservletResponse - The HttpServletResponse of the requestownerKey - A unique identifier of the owner (group) of this uploadIOException - When saving bytes or information of this requests failspublic InputStream getUploadedBytes(String uploadURI) throws IOException, TusException
uploadURI - The URI of the uploadInputStream that will stream the uploaded bytesIOException - When the retreiving the uploaded bytes failsTusException - When the upload is still in progress or cannot be foundpublic InputStream getUploadedBytes(String uploadURI, String ownerKey) throws IOException, TusException
uploadURI - The URI of the uploadownerKey - The key of the owner of this uploadInputStream that will stream the uploaded bytesIOException - When the retreiving the uploaded bytes failsTusException - When the upload is still in progress or cannot be foundpublic UploadInfo getUploadInfo(String uploadURI) throws IOException, TusException
uploadURI - The URI of the uploadIOException - When retrieving the upload information failsTusException - When the upload is still in progress or cannot be foundpublic UploadInfo getUploadInfo(String uploadURI, String ownerKey) throws IOException, TusException
uploadURI - The URI of the uploadownerKey - The key of the owner of this uploadIOException - When retrieving the upload information failsTusException - When the upload is still in progress or cannot be foundpublic void deleteUpload(String uploadURI) throws IOException, TusException
uploadURI - The upload URIIOExceptionTusExceptionpublic void deleteUpload(String uploadURI, String ownerKey) throws IOException, TusException
uploadURI - The upload URIownerKey - The key of the owner of this uploadIOExceptionTusExceptionpublic void cleanup()
throws IOException
IOException - When cleaning failsprotected void processLockedRequest(HttpMethod method, TusServletRequest request, TusServletResponse response, String ownerKey) throws IOException
IOExceptionprotected void executeProcessingByFeatures(HttpMethod method, TusServletRequest servletRequest, TusServletResponse servletResponse, String ownerKey) throws IOException, TusException
IOExceptionTusExceptionprotected void validateRequest(HttpMethod method, javax.servlet.http.HttpServletRequest servletRequest, String ownerKey) throws TusException, IOException
TusExceptionIOExceptionprotected void processTusException(HttpMethod method, TusServletRequest request, TusServletResponse response, String ownerKey, TusException exception) throws IOException
IOExceptionCopyright © 2019. All rights reserved.