Package me.desair.tus.server.upload
Class UploadIdFactory
java.lang.Object
me.desair.tus.server.upload.UploadIdFactory
- Direct Known Subclasses:
TimeBasedUploadIdFactory
,UuidUploadIdFactory
Interface for a factory that can create unique upload IDs. This factory can also parse the upload
identifier from a given upload URL.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract UploadId
createId()
Create a new unique upload ID.protected abstract Serializable
getIdValueIfValid
(String extractedUrlId) Transform the extracted path ID value to a value to use for the upload ID object.Return the URI of the main tus upload endpoint.protected Pattern
Build and retrieve the Upload URI regex pattern.readUploadId
(String url) Read the upload identifier from the given URL.void
setUploadUri
(String uploadUri) Set the URI under which the main tus upload endpoint is hosted.
-
Constructor Details
-
UploadIdFactory
public UploadIdFactory()
-
-
Method Details
-
setUploadUri
Set the URI under which the main tus upload endpoint is hosted. Optionally, this URI may contain regex parameters in order to support endpoints that contain URL parameters, for example /users/[0-9]+/files/upload- Parameters:
uploadUri
- The URI of the main tus upload endpoint
-
getUploadUri
Return the URI of the main tus upload endpoint. Note that this value possibly contains regex parameters.- Returns:
- The URI of the main tus upload endpoint.
-
readUploadId
Read the upload identifier from the given URL.
Clients will send requests to upload URLs or provided URLs of completed uploads. This method is able to parse those URLs and provide the user with the corresponding upload ID.- Parameters:
url
- The URL provided by the client- Returns:
- The corresponding Upload identifier
-
createId
Create a new unique upload ID.- Returns:
- A new unique upload ID
-
getIdValueIfValid
Transform the extracted path ID value to a value to use for the upload ID object. If the extracted value is not valid, null is returned- Parameters:
extractedUrlId
- The ID extracted from the URL- Returns:
- Value to use in the UploadId object, null if the extracted URL value was not valid
-
getUploadUriPattern
Build and retrieve the Upload URI regex pattern.- Returns:
- A (cached) Pattern to match upload URI's
-