Downloading Files using REST API
To download files, you can use the ThingWorx Composer user interface or REST API. Using the REST API provides more control over how files are downloaded. The direct download link to a file islocalhost/Thingworx/Things/SystemRepository/<file.txt>.
You can also use the HTTP accept-ranges header to customize the download behavior.
Using the HTTP accept-ranges Header
The HTTP accept-ranges header allows you to pause or resume a download, and specify a range of bytes to download in a file. The accepted format is bytes=StartIndex-EndIndex.
• bytes=StartIndex-EndIndex - Downloads the content in the specified byte range, including both start and end indexes.
• bytes=StartIndex - Downloads the content from the specified start index to the end of the file, including, StartIndex and lastByteIndex of the file.
• bytes=-endIndex - Downloads the last endIndexBytes. For example, if bytes=-500, the last 500 bytes get downloaded.
Important Considerations for the HTTP accept-ranges Header
• If the endIndex value is greater than the file size, the endIndex is set to the lastFileByteIndex.
• If the bytes range is not specified, the entire file is downloaded.
• Multipart byte ranges are not supported.
HTTP Status Codes for the HTTP accept-ranges Header
• 206 Partial Content— Returned when a valid byte range is successfully downloaded.
• 416 Range Not Satisfiable— Returned when the specified range is invalid or any exception occurs.