Using a File Repository via REST API
In addition to using the Composer UI to download files, you can also use the REST API, which allows for more options when downloading. The direct link to a file is localhost/Thingworx/Things/SystemRepository/<file.txt>, but you can also use the HTTP accept-ranges header for more options.
|
This feature is available in ThingWorx 8.5.9+ and 9.0.2+.
|
Using the HTTP accept-ranges Header
The HTTP accept-ranges header can be used to pause and resume downloads. You can also specify a range of bytes to download, you can start and pause a download, or resume later. The accepted format is bytes=StartIndex-EndIndex.
• bytes=StartIndex-EndIndex - Downloads the content in the given range, Start and EndIndex are included.
• bytes=StartIndex - Downloads the content in the given range, StartIndex and lastByteIndex of File.
• bytes=-endIndex - Downloads the last endIndexBytes. For example, if bytes=-500, the last 500 bytes will be downloaded.
• If the endIndex is greater than the file size, then the endIndex will be set to lastFileByteIndex.
• If the bytes range is not passed, the entire file will be downloaded.
• Multipart ByteRanges are not allowed.
• If you pass ”Range” in the header of an HTTP request and the file is successfully downloaded, a status code of 206 will be returned in the response.
• If you pass “Range” in the header of an HTTP request and any exception occurs, a status code of 416 will be returned in the response.