Can I control the s3 bucket for each upload using TUS

He guys;

Am I able to configure the bucket and key for the final location of an upload file when using the TUS server?

I see that TUS has the s3store option but the bucket is configured ahead of time like so:
tusd -s3-bucket=my-test-bucket.com

When I use the AwsS3 plugin on uppy I am able to control exactly where the file goes. Will I have this level of control if I use TUS?

The reason I need this option is that our SASS application needs to each client’s files uploaded to their own s3 bucket.

Thanks for any pointers!

Hi there,

I can only talk about the tusd server (https://github.com/tus/tusd) here, other tus server implementations (see https://tus.io/implementations.html) may have other answers to your question.

You are not able to dynamically configure the S3 destination bucket for tusd. It can only upload to one S3 bucket and this has to be named when tusd is started. What you could do is to upload all files from all clients to a shared bucket and then copy them to the client’s private bucket after the upload is complete.

I hope that helps.

Okay, thanks Marius…I am using the go version of TUS.

So the moving of the files on upload complete could be done in response to a “post-finish” hook?

Yes, exactly. The post-finish hook is the perfect place for this.

Thanks @marius!

This is looking promising…

If we wanted to take advantage of transloadit’s transforms would that mean that we would have to use transloadit’s TUS server vs using our own self hosted TUS server?

Also, if I’m using the “post-finish” hook I’ll need to somehow relate the TUS id to the corresponding record in our own app database. The uppy “upload-success” event provides an uppy ID but this is not the same as the TUS ID. The TUS ID is part of the final URL, so I suppose I could parse it out and save it to our own representative record in our system so it can be looked up when the final “post-finish” post call happens. But is there an easier way of getting the TUS ID (like it would be amazing if uppy passed this TUS ID back with its own events)

You can do both. Transloadit is able to import from your S3 buckets (see the /s3/import robot at Import files from Amazon S3 | Transloadit). However, you can also upload directly to Transloadit’s servers using our SDKs which can use tus internally.

You could do that but the recommended way is to add metadata to the tus upload. For example, you add your internal record ID as metadata to the tus upload which can then be read by the post-finish how to know what the upload is meant for.

Coming back around 5 YEARS later…

Wouldn’t it be possible to use tusd http hooks to set this dynamically?

This will be possible once s3store: Allow customizing upload ID and object ID by Acconut · Pull Request #1167 · tus/tusd · GitHub is finished.