Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix uploadRemoteFile undefined #4814

Merged
merged 6 commits into from
Dec 12, 2023
Merged

fix uploadRemoteFile undefined #4814

merged 6 commits into from
Dec 12, 2023

Conversation

mifi
Copy link
Contributor

@mifi mifi commented Dec 7, 2023

for some reason, only when testing locally using VITE_COMPANION_URL=https://api2.transloadit.com/companion only we get this error...
i'm thinking for some reason, the remote file gets serialized into state and then de-serialized again causing remote.requestClient to be gone
so I solve it by instead storing the request clients in Uppy

fixes #4791

for some reason, only when testing locally using VITE_COMPANION_URL=https://api2.transloadit.com/companion only
we get this error...
i'm thinking for some reason, the remote file gets serialized into state and then de-serialized again
causing remote.requestClient to be gone
so I solve it by instead storing the request clients in Uppy

fixes #4791
Copy link
Member

@Murderlon Murderlon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a quickfix, this LGTM 👍

But curious how you see this designed ideally. It seems a bit odd to store request clients per ID in Uppy, but register logic them in View, but setting them from providers?

@@ -88,6 +88,9 @@ export default class Url extends UIPlugin {
companionHeaders: this.opts.companionHeaders,
companionCookiesRule: this.opts.companionCookiesRule,
})

this.requestClientId = 'url';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about reusing this.id? And why are we only setting this for the url plugin, not all other providers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a bit hard to see between all the whitespace changes, but i also did the same in View.js (used by providers). as for reusing this.id, it feels a bit error prone, if someone customizes their id, then it could blow up

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But they could also customize requestClientId, no? Should we use .constructor.name instead? That seems unlikely to change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok have now refactored to use constructor.name, but in View.js we have to use this.provider.provider because we cannot get constructor.name

@mifi
Copy link
Contributor Author

mifi commented Dec 8, 2023

Not sure how it’s best implemented TBH, but yea I agree it’s a bit strange to do it like this.

@mifi
Copy link
Contributor Author

mifi commented Dec 8, 2023

argh suddenly the PR has a ton of whitespace changes. i didn't commit this. i think there's something wrong with our prettier setup

@mifi mifi requested review from Murderlon and aduh95 December 8, 2023 15:17
packages/@uppy/core/src/Uppy.js Show resolved Hide resolved
@@ -88,6 +91,8 @@ export default class Url extends UIPlugin {
companionHeaders: this.opts.companionHeaders,
companionCookiesRule: this.opts.companionCookiesRule,
})

this.uppy.registerRequestClient(Url.requestClientId, this.client)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why only Url and not all other providers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not only url, see also changes in ProviderView and SearchProviderView

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a comment then why URL is the only exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, what i'm saying is that URL is not an exception. we do the same inside ProviderView and SearchProviderView

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is an exception because URL is apparently the only one that needs to have it explicitly, while the rest of the plugins have it implicitly through ProviderView?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, not sure what the comment would say.

/**
* Url
*
*/
export default class Url extends UIPlugin {
static VERSION = packageJson.version

static requestClientId = Url.name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
static requestClientId = Url.name
static requestClientId = this.name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You sure that will work? doesn't this imply we have an instance? static happens before we have an instance right?

@arturi arturi merged commit eb8a806 into main Dec 12, 2023
17 checks passed
@arturi arturi deleted the fix-uploadRemoteFile branch December 12, 2023 19:51
@github-actions github-actions bot mentioned this pull request Dec 12, 2023
github-actions bot added a commit that referenced this pull request Dec 12, 2023
| Package                | Version | Package                | Version |
| ---------------------- | ------- | ---------------------- | ------- |
| @uppy/aws-s3           |   3.6.0 | @uppy/instagram        |   3.2.0 |
| @uppy/aws-s3-multipart |  3.10.0 | @uppy/onedrive         |   3.2.0 |
| @uppy/box              |   2.2.0 | @uppy/provider-views   |   3.8.0 |
| @uppy/companion        |  4.12.0 | @uppy/store-default    |   3.2.0 |
| @uppy/companion-client |   3.7.0 | @uppy/tus              |   3.5.0 |
| @uppy/core             |   3.8.0 | @uppy/url              |   3.5.0 |
| @uppy/dropbox          |   3.2.0 | @uppy/utils            |   5.7.0 |
| @uppy/facebook         |   3.2.0 | @uppy/xhr-upload       |   3.6.0 |
| @uppy/google-drive     |   3.4.0 | @uppy/zoom             |   2.2.0 |
| @uppy/image-editor     |   2.4.0 | uppy                   |  3.21.0 |

- @uppy/provider-views: fix uploadRemoteFile undefined (Mikael Finstad / #4814)
- @uppy/companion: fix double tus uploads (Mikael Finstad / #4816)
- @uppy/companion: fix accelerated endpoints for presigned POST  (Mikael Finstad / #4817)
- @uppy/companion: fix `authProvider` property inconsistency (Mikael Finstad / #4672)
- @uppy/companion:  send certain onedrive errors to the user (Mikael Finstad / #4671)
- meta: fix typo in `lockfile_check.yml` name (Antoine du Hamel)
- @uppy/aws-s3: change Companion URL in tests (Antoine du Hamel)
- @uppy/set-state: fix types (Antoine du Hamel)
- @uppy/companion: Provider user sessions (Mikael Finstad / #4619)
- meta: fix `js2ts` script on Node.js 20+ (Merlijn Vos / #4802)
- @uppy/companion-client: avoid unnecessary preflight requests (Antoine du Hamel / #4462)
- meta: Migrate to AWS-SDK V3 syntax (Artur Paikin / #4810)
- @uppy/utils: fix import in test files (Antoine du Hamel / #4806)
- @uppy/core: Fix onBeforeFileAdded with Golden Retriever (Merlijn Vos / #4799)
- @uppy/image-editor: respect `cropperOptions.initialAspectRatio` (Lucklj521 / #4805)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Undefined "uploadRemoteFile" when using RemoteSources
4 participants