Handling multiple endpoints?

I’m new to tus and have just been reading up on how it works to see if I can implement it into my current website.

Currently I have different API endpoints for uploading various files for different purposes. Like one for uploading a game (in a zip file). Another for uploading a thumbnail image. They get stored in different locations and there’s additional processing / database entries created when those happen.

It appears that tus acts as a single server endpoint (/files for example) and all files get uploaded to that one endpoint. How would you handle needing to differentiate between different types of content being uploaded and needing to be saved to different locations (in my case different s3 buckets) or different database fields being updated.

Hi there and welcome to the tus forum! There are basically two ways to solve your situation:

  1. Run multiple tus servers at different endpoints which store the uploads on different locations. This is easy to setup but can be though to maintain and scale as the number of file types increases.
  2. Run a single tus server but send additional information with each upload identifying its type using Upload Metadata. This metadata is attached during the Upload Creation and helps the server to know what it should do with the file. The further file processing depends on your tus server. For example, tusd has the post-finish hook (https://github.com/tus/tusd/blob/master/docs/hooks.md#post-finish) which gets invoked after the file is uploaded and also gets access to the upload’s metadata. In this hook, you can then write your custom logic for processing the different file types.

We generally recommend using the second approach since it is a lot easier to maintain and scale. Hope that helps!