Class UploadIdFactory

java.lang.Object
me.desair.tus.server.upload.UploadIdFactory
Direct Known Subclasses:
TimeBasedUploadIdFactory, UuidUploadIdFactory

public abstract class UploadIdFactory extends Object
Interface for a factory that can create unique upload IDs. This factory can also parse the upload identifier from a given upload URL.
  • Constructor Details

    • UploadIdFactory

      public UploadIdFactory()
  • Method Details

    • setUploadUri

      public void setUploadUri(String uploadUri)
      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

      public String 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

      public UploadId readUploadId(String url)
      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

      public abstract UploadId createId()
      Create a new unique upload ID.
      Returns:
      A new unique upload ID
    • getIdValueIfValid

      protected abstract Serializable getIdValueIfValid(String extractedUrlId)
      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

      protected Pattern getUploadUriPattern()
      Build and retrieve the Upload URI regex pattern.
      Returns:
      A (cached) Pattern to match upload URI's