Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
A range request asks the server to send only part of a file. A single GET request downloads the whole file. With range requests, you can download a large file in several smaller requests, or resume an interrupted download instead of starting it again from the beginning.
Request a range
To request part of a file, send the Range header with the positions of the first and last bytes you want. Positions start at 0, and the range includes both positions. For example, bytes=0-1048575 requests the first 1 MiB of a 10 MiB file:
GET /api/3.0/fs/files/Volumes/main/default/my-volume/large-file.bin
Range: bytes=0-1048575
206 Partial Content
Accept-Ranges: bytes
Content-Range: bytes 0-1048575/10485760
Content-Length: 1048576
ETag: "33a64df551425fcc55e4d42a148795d9f25f89d4"
<binary data>
The 206 Partial Content response contains only the requested bytes. The Content-Range header shows which bytes the response contains and the total size of the file.
To request everything from a position to the end of the file, omit the last position, for example bytes=1048576-. If the last position is past the end of the file, the response contains the bytes up to the end of the file.
A HEAD request with a Range header returns the same status and headers as the matching GET request, without the body.
Resume an interrupted download
If a download is interrupted, you don't have to download the whole file again. Request the remaining bytes with a range that starts at the first byte you have not received.
The file can change between your requests, and combining bytes from different versions of the file corrupts the result. To prevent this, send If-Match with the ETag from your first response. If the file is unchanged, the server returns the remaining bytes:
GET /api/3.0/fs/files/Volumes/main/default/my-volume/large-file.bin
Range: bytes=1048576-
If-Match: "33a64df551425fcc55e4d42a148795d9f25f89d4"
206 Partial Content
Accept-Ranges: bytes
Content-Range: bytes 1048576-10485759/10485760
Content-Length: 9437184
<binary data>
If the file changed, the server returns 412 Precondition Failed instead, and you can start the download again.