Companion's URL controller should avoid getting the URL metadata if it already knows the file size
See original GitHub issueThe /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:
- Created 2 years ago
- Comments:5
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.
@arturi any preferences?