# Can I control the s3 bucket for each upload using TUS

**URL:** <https://community.transloadit.com/t/can-i-control-the-s3-bucket-for-each-upload-using-tus/15069>\
**Category:** Tus\
**Created:** [September 24, 2019, 2:31pm UTC](https://community.transloadit.com/t/can-i-control-the-s3-bucket-for-each-upload-using-tus/15069 "2019-09-24T14:31:06Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryantomaselli](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.transloadit.com/ryantomaselli/32/165_2.png) [@ryantomaselli](https://community.transloadit.com/u/ryantomaselli)\
**Post date:** [September 24, 2019, 2:31pm UTC](https://community.transloadit.com/t/can-i-control-the-s3-bucket-for-each-upload-using-tus/15069/1 "2019-09-24T14:31:06Z")

</div>

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](http://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!

---

<div class="post-metadata">

**Author:** ![marius](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.transloadit.com/marius/32/572_2.png) [@marius](https://community.transloadit.com/u/marius)\
**Post date:** [September 24, 2019, 4:43pm UTC](https://community.transloadit.com/t/can-i-control-the-s3-bucket-for-each-upload-using-tus/15069/2 "2019-09-24T16:43:53Z")

</div>

Hi there,

I can only talk about the tusd server ([https://github.com/tus/tusd](https://github.com/tus/tusd)) here, other tus server implementations (see [https://tus.io/implementations.html](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.

---

<div class="post-metadata">

**Author:** ![ryantomaselli](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.transloadit.com/ryantomaselli/32/165_2.png) [@ryantomaselli](https://community.transloadit.com/u/ryantomaselli)\
**Post date:** [September 24, 2019, 5:07pm UTC](https://community.transloadit.com/t/can-i-control-the-s3-bucket-for-each-upload-using-tus/15069/3 "2019-09-24T17:07:06Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![marius](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.transloadit.com/marius/32/572_2.png) [@marius](https://community.transloadit.com/u/marius)\
**Post date:** [September 24, 2019, 8:06pm UTC](https://community.transloadit.com/t/can-i-control-the-s3-bucket-for-each-upload-using-tus/15069/4 "2019-09-24T20:06:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ryantomaselli](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.transloadit.com/ryantomaselli/32/165_2.png) [@ryantomaselli](https://community.transloadit.com/u/ryantomaselli)\
**Post date:** [September 26, 2019, 7:03pm UTC](https://community.transloadit.com/t/can-i-control-the-s3-bucket-for-each-upload-using-tus/15069/5 "2019-09-26T19:03:15Z")

</div>

> [@ryantomaselli](#):
>
> “post-finish” hook

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)

---

<div class="post-metadata">

**Author:** ![marius](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.transloadit.com/marius/32/572_2.png) [@marius](https://community.transloadit.com/u/marius)\
**Post date:** [September 27, 2019, 1:40pm UTC](https://community.transloadit.com/t/can-i-control-the-s3-bucket-for-each-upload-using-tus/15069/6 "2019-09-27T13:40:55Z")

</div>

> [@ryantomaselli](#):
>
> 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?

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](https://transloadit.com/services/file-importing/s3-import/)). However, you can also upload directly to Transloadit’s servers using our SDKs which can use tus internally.

> [@ryantomaselli](#):
>
> 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 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.

---

<div class="post-metadata">

**Author:** ![YesThatGy](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.transloadit.com/yesthatgy/32/1205_2.png) [@YesThatGy](https://community.transloadit.com/u/YesThatGy)\
**Post date:** [September 9, 2024, 3:46pm UTC](https://community.transloadit.com/t/can-i-control-the-s3-bucket-for-each-upload-using-tus/15069/7 "2024-09-09T15:46:57Z")

</div>

Coming back around 5 YEARS later…

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

---

<div class="post-metadata">

**Author:** ![marius](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.transloadit.com/marius/32/572_2.png) [@marius](https://community.transloadit.com/u/marius)\
**Post date:** [September 9, 2024, 3:50pm UTC](https://community.transloadit.com/t/can-i-control-the-s3-bucket-for-each-upload-using-tus/15069/8 "2024-09-09T15:50:27Z")

</div>

This will be possible once [s3store: Allow customizing upload ID and object ID by Acconut · Pull Request #1167 · tus/tusd · GitHub](https://github.com/tus/tusd/pull/1167) is finished.
