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

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!

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

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:

    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,

/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?

A few more details:

In the js-client invocation:

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:

    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,

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

To initialize companion:

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/
  2. Provide companion at 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?

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…

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.

Hello @alvacouch, have you configured tusd and nginx exactly according to tusd/faq.md at master · tus/tusd · GitHub?
Are there logs from Companion and tusd you can share?

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?

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

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

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

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.

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