Oliver McPhee
Oliver McPhee

Reputation: 1056

Which REST method to use for Download

Our API will allow users to download files (10mb - 500mb).

The REST endpoint will be

/downloads/*content-id*

Where the content id is a reference to a file on our server.

I assume that the HTTP Method should be a GET, as it is trying to retrieve something. However, since I want users to be able to pause downloads to resume later, I need to also pass a bytes-received parameter to the endpoint.

Should I do this as a query param?

/downloads/*content-id*?bytesReceived=123

Or should I add the bytes-received to the request body, and if so, should I not be using GET anymore?

Also, as a second q. I am using the octet-stream content type to download the files - as I have been told this content-type will best allow me to pause the downloads and resume later. When unpacked, the file will be some HTML5 content (with js/css). Is this the best way?

Upvotes: 7

Views: 8650

Answers (1)

Opal
Opal

Reputation: 84784

You should use GET method since you're getting the particular resource. You can't pass bytesReceived via body since GET does not have a body. Instead use appropriate header, it's called Range, please see here.

Upvotes: 6

Related Questions