home/More/Self Service Portal/Rest API/FileLink byte ranges

FileLink byte ranges

Partial downloads

The V2 file-link endpoint accepts StartAtByte and EndAtByte in the request body:

POST /metadata/v2/filelink

These optional properties restrict the file content returned when the generated download link is used. They are offsets into the uncompressed file and use a zero-based, half-open range:

[StartAtByte, EndAtByte)

StartAtByte is included and EndAtByte is excluded.

Property reference

Property Type Meaning
StartAtByte Nullable 64-bit integer Zero-based offset of the first byte returned. If omitted or null, the download starts at byte 0.
EndAtByte Nullable 64-bit integer Zero-based offset immediately after the last byte returned. If omitted or null, the download continues to the end of the file.

When EndAtByte is supplied, the download size is:

download size = EndAtByte - StartAtByte

When EndAtByte is omitted, the download size is:

download size = file size - StartAtByte

The offsets and sizes are measured in bytes, not characters, records, or kilobytes.

Examples

Assume a 1,000-byte file, with valid byte indexes from 0 to 999.

StartAtByte EndAtByte Outcome Size
omitted omitted Entire file, bytes 0 through 999 1,000 bytes
100 omitted Byte 100 through the end of the file 900 bytes
omitted 100 Bytes 0 through 99 100 bytes
100 200 Bytes 100 through 199 100 bytes
100 101 Byte 100 only 1 byte
100 100 Empty response body 0 bytes

For example, to request bytes 100 through 199:

{
  "FileName": "example.dat",
  "FileMD5Hash": "<file MD5 hash>",
  "StartAtByte": 100,
  "EndAtByte": 200
}

The V2 API uses the Pascal-case JSON property names shown above.

Downloading to the end of the file

Omit EndAtByte to download through the final byte. The current download service rejects an explicitly supplied EndAtByte equal to the file size, even though the property otherwise behaves as an exclusive boundary.

For a 1,000-byte file, use this request to download bytes 900 through 999:

{
  "FileName": "example.dat",
  "FileMD5Hash": "<file MD5 hash>",
  "StartAtByte": 900,
  "EndAtByte": null
}

Do not set EndAtByte to 1000. Also, because EndAtByte is excluded, setting it to 999 would stop at byte 998 and would not include the final byte.