tusd icon indicating copy to clipboard operation
tusd copied to clipboard

HEAD Request Handling

Open alameenlr opened this issue 3 years ago • 5 comments

HEAD Request Handling Currently majority of CDN services are not responding for HEAD Request properly. Converting HEAD requests to GET and tus servers returns 204 and uploads starts from the begging...! Why tus can't use GET Method instead of HEAD??

Setup details Please provide following details, if applicable to your situation:

  • Operating System: Linux
  • Used tusd version: 1.0
  • Used tusd data storage: AWS S3
  • Used tusd configuration: [-s3-bucket,-s3-endpoint,-s3-object-prefix,-max-size,-timeout,-port,-hooks-http,-hooks-http-retry,-hooks-http-backoff,-hooks-enabled-events ,-behind-proxy]
  • Used tus client library: tus-js-client

alameenlr avatar May 07 '21 14:05 alameenlr

Why tus can't use GET Method instead of HEAD??

The are mainly two reasons:

  • tusd is designed for uploads and not for serving files. I would not recommend using tusd for serving content or even behind a CDN. You should use a proper server for this job.
  • The tus protocol does not need to fetch the content of a file but only the metadata associated with an upload. Therefore HEAD requests fit semantically better than GET requests.

Acconut avatar May 09 '21 14:05 Acconut

Okay.

How the tusd, server identify files while resuming uploads after a long time? What are the parameters used to identify the upload.?

alameenlr avatar May 11 '21 17:05 alameenlr

What are the parameters used to identify the upload.?

Each upload has an ID that is included in the URL that the HEAD/PATCH requests are sent to.

Acconut avatar May 11 '21 21:05 Acconut

This was I did.

  1. Uploaded a file with name Falcon F16.mp4
  2. I've refreshed the page when upload at 30%
  3. Again I stated the upload, it is started from 30%

How it is possible. with out url-with-id? What are the parameters used to identify the upload.?

alameenlr avatar May 12 '21 12:05 alameenlr

Ah, I see what your question is. tus-js-client uses a combination of file name, file size, modification date and mime type to see if the file was already uploaded (or began to upload) before: https://github.com/tus/tus-js-client/blob/master/lib/browser/fingerprint.js#L17-L24

It's not a perfect heuristic but has served us very well in the past.

Acconut avatar May 13 '21 13:05 Acconut