# How does an uploaded file get from uppy companion to tusd?

**URL:** <https://community.transloadit.com/t/how-does-an-uploaded-file-get-from-uppy-companion-to-tusd/16150>\
**Category:** Uppy\
**Created:** [July 7, 2022, 1:22pm UTC](https://community.transloadit.com/t/how-does-an-uploaded-file-get-from-uppy-companion-to-tusd/16150 "2022-07-07T13:22:56Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![alvacouch](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@alvacouch](https://community.transloadit.com/u/alvacouch)\
**Post date:** [July 7, 2022, 1:22pm UTC](https://community.transloadit.com/t/how-does-an-uploaded-file-get-from-uppy-companion-to-tusd/16150/1 "2022-07-07T13:22:56Z")

</div>

I just about have companion working but there is a crucial step I’m missing… Uploads from the local filesystem work fine direct to tusd.

When I upload a file from google drive, it makes it to companion scratch space, but never gets transferred to tusd.(the reference solution). The upload hangs forever, even though companion has a complete copy.

Both companion and tusd are behind NGINX reverse proxy.

Does the request to transfer the file from companion to tusd come directly from companion? If so, I am giving companion the wrong tusd address.

Thanks!

---

<div class="post-metadata">

**Author:** ![alvacouch](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@alvacouch](https://community.transloadit.com/u/alvacouch)\
**Post date:** [July 7, 2022, 6:02pm UTC](https://community.transloadit.com/t/how-does-an-uploaded-file-get-from-uppy-companion-to-tusd/16150/2 "2022-07-07T18:02:49Z")

</div>

A few more details:  
In the JS-client script:

```auto
uppy.use(Uppy.Tus, { endpoint: 'https://cuahsi-dev-1.hydroshare.org/upload/' });
...
uppy.use(Uppy.GoogleDrive, {
  target: Uppy.Dashboard,
  companionUrl: 'https://cuahsi-dev-1.hydroshare.org/companion/'
});

```

In NGINX.conf:

```auto
    location /upload/ {
        # doesn't work for some reason involving docker networking setup:
        proxy_pass http://tusd:1080;
        ...
    }
    location /companion/ {
        proxy_pass http://uppy:3020/;
        ...
    }

```

The symbols `tusd` and `uppy` are defined in `/etc/hosts`.  
In starting up `tusd`,

```auto
/usr/local/bin/tusd -base-path /upload/ -behind-proxy

```

What I think I’m doing is to expose tusd as `https://cuahsi-dev-1.hydroshare.org/upload` and companion as `https://cuahsi-dev-1.hydroshare.org/companion`.

The problem is that – according to the JavaScript debugging console, the `tusd` URL that is given to `companion` is the same external one that is declared to the js-client. Since `companion` is running behind a proxy, it can’t contact `tusd` that way.

I think the way I have to fix this is to make it possible for `companion` to contact `tusd’ via the public URL even though it is behind the proxy. Is this correct?

---

<div class="post-metadata">

**Author:** ![alvacouch](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@alvacouch](https://community.transloadit.com/u/alvacouch)\
**Post date:** [July 7, 2022, 6:26pm UTC](https://community.transloadit.com/t/how-does-an-uploaded-file-get-from-uppy-companion-to-tusd/16150/3 "2022-07-07T18:26:16Z")

</div>

A few more details:

In the js-client invocation:

```auto
uppy.use(Uppy.Tus, { endpoint: 'https://cuahsi-dev-1.hydroshare.org/upload/' });

uppy.use(Uppy.GoogleDrive, {
  target: Uppy.Dashboard,
  companionUrl: 'https://cuahsi-dev-1.hydroshare.org/companion/'
});

```

In NGINX configuration:

```auto
    location /upload/ {
        proxy_pass http://tusd:1080;
        ...
    }
    location /companion/ {
        proxy_pass http://uppy:3020/;
        ...
    }

```

Where `tusd` and `uppy` are in /etc/hosts.

To initialize `tusd`,

```auto
/usr/local/bin/tusd -base-path /upload/ -behind-proxy 

```

To initialize `companion`:

```auto
export COMPANION_IMPLICIT_PATH="/companion"
...
companion

```

**What I think I am doing** is to

1. Provide tusd at [https://cuahsi-dev-1.hydroshare.org/upload/](https://cuahsi-dev-1.hydroshare.org/upload/)
2. Provide companion at [https://cuahsi-dev-1.hydroshare.org/companion/](https://cuahsi-dev-1.hydroshare.org/companion/)

The JavaScript console tells me that when companion is called, the **external** address of upload is being passed.

What I think I need to do is to arrange /etc/hosts so that the external address points to the internal one in /etc/hosts. Is this correct?

---

<div class="post-metadata">

**Author:** ![alvacouch](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@alvacouch](https://community.transloadit.com/u/alvacouch)\
**Post date:** [July 8, 2022, 7:39pm UTC](https://community.transloadit.com/t/how-does-an-uploaded-file-get-from-uppy-companion-to-tusd/16150/4 "2022-07-08T19:39:40Z")

</div>

I’m having incredible trouble convincing uppy companion, that tusd is running at a subURL `https://cuahsi-dev-1.hydroshare.org/upload/...` It seems to strip that off and redirects to `https://cuahsi-dev-1.hydroshare.org/connect/...` URL without the `upload` prefix.

Is there any way I can convince if to use that prefix when working through the callbacks after google drive authentication and permission?

It seems that in a lot of ways, uppy companion presumes that tusd is running at the root of the hrml hierarchy…

---

<div class="post-metadata">

**Author:** ![Merlijn](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.transloadit.com/merlijn/32/1382_2.png) [@Merlijn](https://community.transloadit.com/u/Merlijn)\
**Post date:** [July 11, 2022, 10:47am UTC](https://community.transloadit.com/t/how-does-an-uploaded-file-get-from-uppy-companion-to-tusd/16150/5 "2022-07-11T10:47:08Z")

</div>

Hi, I’m not too sure what is required here but I have let @marius and Mikeal know about this. Perhaps they can shed some light.

---

<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:** [July 16, 2022, 12:26pm UTC](https://community.transloadit.com/t/how-does-an-uploaded-file-get-from-uppy-companion-to-tusd/16150/6 "2022-07-16T12:26:42Z")

</div>

Hello @alvacouch, have you configured tusd and nginx exactly according to [tusd/faq.md at master · tus/tusd · GitHub](https://github.com/tus/tusd/blob/master/docs/faq.md#can-i-run-tusd-behind-a-reverse-proxy)?  
Are there logs from Companion and tusd you can share?

---

<div class="post-metadata">

**Author:** ![mifi](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.transloadit.com/mifi/32/603_2.png) [@mifi](https://community.transloadit.com/u/mifi)\
**Post date:** [July 16, 2022, 7:13pm UTC](https://community.transloadit.com/t/how-does-an-uploaded-file-get-from-uppy-companion-to-tusd/16150/7 "2022-07-16T19:13:11Z")

</div>

Does it work if you assign one subdomain for each companion and tusd? If not, does it work if you try to instead upload to Transloadit’s demo tus [tusd.tusdemo.net](http://tusd.tusdemo.net)?

---

<div class="post-metadata">

**Author:** ![ckcabs](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@ckcabs](https://community.transloadit.com/u/ckcabs)\
**Post date:** [March 14, 2023, 3:11pm UTC](https://community.transloadit.com/t/how-does-an-uploaded-file-get-from-uppy-companion-to-tusd/16150/8 "2023-03-14T15:11:20Z")

</div>

Hi Alvacouch/community,

Did you ever solve this?

We have it running the same way behind an apache reverse proxy, our main problem was our upload url wasn’t configured properly

We are still none the wiser how an uploaded file gets from companion to tusd. How does companion know the tusd endpoint?  
can the tusd endpoint be explicitly set in companion?  
would love some clarification

thanks

---

<div class="post-metadata">

**Author:** ![alvacouch](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@alvacouch](https://community.transloadit.com/u/alvacouch)\
**Post date:** [March 14, 2023, 5:24pm UTC](https://community.transloadit.com/t/how-does-an-uploaded-file-get-from-uppy-companion-to-tusd/16150/9 "2023-03-14T17:24:19Z")

</div>

It’s working now. What was wrong was complicated. Several wrongs don’t make a right.

---

<div class="post-metadata">

**Author:** ![ckcabs](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@ckcabs](https://community.transloadit.com/u/ckcabs)\
**Post date:** [March 14, 2023, 5:29pm UTC](https://community.transloadit.com/t/how-does-an-uploaded-file-get-from-uppy-companion-to-tusd/16150/10 "2023-03-14T17:29:01Z")

</div>

Thats great news. can you shed any light on my question?

---

<div class="post-metadata">

**Author:** ![alvacouch](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@alvacouch](https://community.transloadit.com/u/alvacouch)\
**Post date:** [March 14, 2023, 7:49pm UTC](https://community.transloadit.com/t/how-does-an-uploaded-file-get-from-uppy-companion-to-tusd/16150/11 "2023-03-14T19:49:23Z")

</div>

It’s complicated. Let me look at my notes. The answer is not easy. I’m putting the finishing touches on our uppy deployment so it won’t take too long, but I can’t give a definitive answer without looking back on my detailed set of discoveries. I’ll get back to you on this.

---

<div class="post-metadata">

**Author:** ![ckcabs](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@ckcabs](https://community.transloadit.com/u/ckcabs)\
**Post date:** [March 15, 2023, 3:12pm UTC](https://community.transloadit.com/t/how-does-an-uploaded-file-get-from-uppy-companion-to-tusd/16150/12 "2023-03-15T15:12:35Z")

</div>

Good luck finishing your implementation. just about to look at changing the file uploaded to the original filename - have you done this?

No worries, found the answer i was looking for to my orginial question  
You specify the `endpoint` option to the Tus plugin in the uppy client. Then Uppy will send this endpoint to Companion, and companion will upload from the provider (e.g. google drive) to that tus endpoint. Note that you will restrict the allowed urls in companion with the option “ **uploadUrls** ” / COMPANION\_UPLOAD\_URLS
