question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Companion's URL controller should avoid getting the URL metadata if it already knows the file size

See original GitHub issue

The /get/ endpoint of the URL controller within Companion (https://github.com/transloadit/uppy/blob/master/packages/%40uppy/companion/src/server/controllers/url.js#L53) initially makes a HEAD request for the URL (via getURLMeta) to find out the file size. It then triggers the upload using that file size as an input. This initial HEAD request appears to be unnecessary because the request sent to the /get endpoint already contains the size. The suggestion is that getURLMeta only be called if the size is not already present in the request to /get (in case there is some edge case where it’s not available).

Why is this important? We are trying to send a S3 presigned URL to Companion (via our own custom Uppy plugin). We have generated the presigned URL for the S3 object but it’s only valid for GET requests. If you try to make a HEAD request with that URL, it will fail. From what I can tell in S3 documentation, there’s no way around this - presigned S3 URLs for different HTTP verbs must use different presigned URLs. Therefore, this is a problem - we can only send a single URL to Companion and it will always try to perform both HEAD and GET requests with it.

Alternatively, since we are passing the file size in the request body for /get (just as the Uppy URL plugin does already), the HEAD request could be avoided and the URL could be used just for the GET operation.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
mificommented, Aug 30, 2021

I tried to look into (3) Rewrite the Uploader so that it doesn’t need to know the size in advance, but it turns out that the uppy client already asks for metadata before downloading, which also is the same HEAD request, so changing the uploader will not solve anything: https://github.com/transloadit/uppy/blob/8e4fae911af76b359f50faf667eb5ad118c6e8a1/packages/%40uppy/companion/src/server/controllers/url.js#L11 So the only solution that I can see that will work is (1) and (2). 2 should be the most compliant with servers so I’ll do that.

0reactions
mificommented, Jul 26, 2021

@arturi any preferences?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Routing to controller actions in ASP.NET Core
Learn how ASP.NET Core MVC uses Routing Middleware to match URLs of incoming requests and map them to actions.
Read more >
Sending core data to watchOS 2 - ios
I know I need to find the URL of the CoreData stack and send that along with the metadata. I think I am...
Read more >
Retrieving file information
This lesson demonstrates how to query the server app's FileProvider to retrieve a file's MIME type and size. Retrieve a file's MIME type....
Read more >
Companion
Companion handles the server-to-server communication between your server and file storage providers such as Google Drive, Dropbox, Instagram, ...
Read more >
App Store Review Guidelines
Customers should know what they're getting when they download or buy your app, so make sure all your app metadata, including privacy ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found