# Using Companion for getting access to Google Drive, etc

**URL:** <https://community.transloadit.com/t/using-companion-for-getting-access-to-google-drive-etc/17439>\
**Category:** Uppy\
**Created:** [January 22, 2025, 1:54pm UTC](https://community.transloadit.com/t/using-companion-for-getting-access-to-google-drive-etc/17439 "2025-01-22T13:54:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jakkir](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.transloadit.com/jakkir/32/1304_2.png) [@jakkir](https://community.transloadit.com/u/jakkir)\
**Post date:** [January 22, 2025, 1:54pm UTC](https://community.transloadit.com/t/using-companion-for-getting-access-to-google-drive-etc/17439/1 "2025-01-22T13:54:50Z")

</div>

Hello!

I’m looking information if Transloadit solutions will be suitable for my company needs.

We’re developing application - (.Net WebApi + Angular frontend), but every client gets instalator and has own instance locally hosted - there is no web hosted app.

File upload from local drive to app is already implemented using TUS (tusdotnet on webapi side as server and tus-js-client on frontend side).

Now, we would like to extend functionality to have intergation with Google Drive/Dropbox/Box and allow users to select files from their webdrives and upload to our application for future processing. For now - no need to do anything with those files, just need to authorize, browse them and upload to our app.

I did a quick POC:

```auto
export class UploadManagerComponent
    extends ManageGenericListComponent
    implements OnInit
{
    private fileUploadUrl: string = getEndpoint('fileUploadUrl');
    public dashboardModalProps = {
        inline: true,
        width: 'auto',
    };
    public uppy: Uppy = new Uppy({
        debug: true,
        autoProceed: true,
    });
    constructor(
        protected readonly store: Store<fromRoot.State>,
        public readonly commonTab: CommonTabService,
        public readonly entityUpdateService: EntityUpdateService,
        public readonly tEngine: TranslationEngineService,
        public readonly iconService: CustomIconService,
        public readonly _confirmationService: ConfirmationService
    ) {
        super(
            store,
            entityUpdateService,
            _confirmationService,
            tEngine,
            iconService
        );
    }
    ngOnInit() {
        super.ngOnInit();
        const companionAllowedHosts = [
            'https://localhost:2402',
            'http://localhost:3020',
        ];
        const token = getAuthenticationToken();
        this.uppy.on('file-added', file => {
            console.warn('file added to uppy:', file);
            let importOptions: ImportOptionsMeta = {
                fileName: file.name,
            };
            this.uppy.setMeta({ importOptions: JSON.stringify(importOptions) });
        });
        this.uppy
            .use(Dashboard)
            .use(Transloadit, {
                assemblyOptions: {
                    params: {
                        auth: { key: 'auth key from Credentials sections in Transloadit portal' },
                    },
                },
            })
            .use(GoogleDrive, {
                companionUrl: 'https://companion.uppy.io/',
                companionAllowedHosts: companionAllowedHosts,
            })
            // .use(Dropbox, {
            // companionUrl: 'https://companion.uppy.io',
            // companionAllowedHosts: companionAllowedHosts,
            // })
            .use(Tus, {
                endpoint: this.fileUploadUrl,
                retryDelays: [0, 1000, 3000, 5000],
                headers: {
                    Authorization: `Bearer ${token}`,
                },
            });
    }
}

```

I setup locally hosted standalone companion app.  
Created a google app so I get key and secret from google for authorization.  
And it worked fine! _(above code example is adjusted to use hosted companion)_

Now, the question - we would like to avoid maintaining own Companion (and google, dropbox, box apps and all credentials related to it) and use Transloadit hosted companion. Tried to use [https://companion.uppy.io](https://companion.uppy.io) mentioned in docs but cors are failing:

```auto
Access to fetch at 'https://companion.uppy.io/drive/list/root' from origin 'https://localhost:2402' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

```

Is using Transloadit hosted Companion in such scenario even possible?  
All requests will be always coming from [https://localhost:2402](https://localhost:2402), is it possible to configure cors somehow?

Would love to hear what are the options and implementation tips. Or if standalone app is the only way to handle that.

Regards,  
Jakub

---

<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:** [January 22, 2025, 2:40pm UTC](https://community.transloadit.com/t/using-companion-for-getting-access-to-google-drive-etc/17439/2 "2025-01-22T14:40:40Z")

</div>

Hi, once this PR is merged: [Allow Transloadit-hosted Companion with other uploaders by Murderlon · Pull Request #5558 · transloadit/uppy · GitHub](https://github.com/transloadit/uppy/pull/5558)

You can use Transloadit-hosted Companion only for your remote files and continue to use another uploader for you local files (in your case tus)

It would work like this:

1. Sign up for Transloadit
2. [Create a template to export to S3](https://transloadit.com/demos/file-exporting/store-uploaded-files-on-s3/)
3. [Add your S3 credentials](https://transloadit.com/docs/topics/template-credentials/)
4. Configure Uppy to only use `@uppy/transloadit` for remote files:

```js
import { COMPANION_URL, COMPANION_ALLOWED_HOSTS } from '@uppy/transloadit';

uppy.use(Tus, { /* ... */ })
uppy.use(Transloadit, { companionOnly: true /* ... */ })
uppy.use(Dropbox, {
	companionUrl: COMPANION_URL,
	companionAllowedHosts: COMPANION_ALLOWED_HOSTS,
});

```

---

<div class="post-metadata">

**Author:** ![jakkir](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.transloadit.com/jakkir/32/1304_2.png) [@jakkir](https://community.transloadit.com/u/jakkir)\
**Post date:** [January 22, 2025, 3:01pm UTC](https://community.transloadit.com/t/using-companion-for-getting-access-to-google-drive-etc/17439/3 "2025-01-22T15:01:06Z")

</div>

Thanks for reply - it looks like something we can use!

But, export to S3 will be needed? Or it’s just an empty template cause I need to have some template to get COMPANION\_URL?

And what would be the correct COMPANION\_URL? The one mentioned in doc is for general use ([https://companion.uppy.io](https://companion.uppy.io)) ?  
Or do I need to create own empty assembly/template? Reading docs, can’t really figure it out.

---

<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:** [January 22, 2025, 3:18pm UTC](https://community.transloadit.com/t/using-companion-for-getting-access-to-google-drive-etc/17439/4 "2025-01-22T15:18:14Z")

</div>

Sorry I was mistaken that your files end up in S3. You can use [any export robot](https://transloadit.com/services/file-exporting/).

You can never use [https://companion.uppy.io](https://companion.uppy.io), it’s only for [https://uppy.io/examples](https://uppy.io/examples). You can import the URL for hosted companion from @uppy/transloadit (or hardcode to [https://api2.transloadit.com/companion](https://api2.transloadit.com/companion))

Note that until that PR is merged your would also have to use `@uppy/transloadit` for your local files.

---

<div class="post-metadata">

**Author:** ![jakkir](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.transloadit.com/jakkir/32/1304_2.png) [@jakkir](https://community.transloadit.com/u/jakkir)\
**Post date:** [January 22, 2025, 3:43pm UTC](https://community.transloadit.com/t/using-companion-for-getting-access-to-google-drive-etc/17439/5 "2025-01-22T15:43:51Z")

</div>

Regarding export robot - the TUS server is hosted locally. Every client has own, local hosted application (and own local hosted TUS server - not available over internet) so I guess I can’t use any of them.

All files must be handled locally on the user computer - companion is just needed to authorize for Google Drive/Dropbox/Box.

That’s my scenario I’m trying to figure out how to make it work.

[https://api2.transloadit.com/companion](https://api2.transloadit.com/companion) - are there any quotas or limits for use?

---

<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:** [January 22, 2025, 3:53pm UTC](https://community.transloadit.com/t/using-companion-for-getting-access-to-google-drive-etc/17439/6 "2025-01-22T15:53:12Z")

</div>

What storage do you use with tus? If it’s file disk storage and the tus server is not reachable over the internet then it will be a bit harder. Perhaps you could use `notify_url` in your template to let your backend know when the file made it from Companion into Transloadit to then download and move it into the appropriate file storage.

> [@jakkir](#):
>
> companion is just needed to authorize for Google Drive/Dropbox/Box.

Companion never sends files to the client, the whole point is that it saves bandwidth. With hosted Companion, your files must go through the Transloadit [template](https://transloadit.com/docs/topics/templates/) flow. In there, you can use some Robots to forward your files to wherever needed.

If you only import and export, no other Robots, then you will pay for [10% of the file size](https://transloadit.com/docs/faq/discounts/) that you move through Transloadit.

---

<div class="post-metadata">

**Author:** ![jakkir](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.transloadit.com/jakkir/32/1304_2.png) [@jakkir](https://community.transloadit.com/u/jakkir)\
**Post date:** [January 22, 2025, 5:06pm UTC](https://community.transloadit.com/t/using-companion-for-getting-access-to-google-drive-etc/17439/7 "2025-01-22T17:06:54Z")

</div>

It’s a local blob storage. Backend does not have public ip, it’s just a local host on client computer - nothing I could use as notify\_url.  
So, I guess the standalone companion is the only way to handle that case.
