Photo and Drive Service (PDS) provides multiple methods for you to download the files stored in PDS. This meets your requirements in different download scenarios.
Download a file by using download URLs
You can call the GetDownloadUrl operation to obtain a temporary download URL of a file.
By default, a download URL of a file is valid for 15 minutes. A download URL can be valid for up to 32 hours. After you obtain a download URL of a file, you must use the download URL to download the file within the validity period. If the download URL expires, you must call the GetDownloadUrl operation again to obtain another download URL of the file. If you have started to download the file within the validity period of the download URL and the download is not interrupted, the download is not affected by the expiration of the download URL.
Download a file by using the resumable download feature
If you download a large file by using a download URL and the download is suspended, you can use the resumable download feature to resume the download from the position where the download is suspended. To use the resumable download feature, specify the Range header in the download request.
The valid values of the Range header range from 0 to the number of bytes in the file minus 1. Examples:
Range: bytes=0-499 specifies the first 500 bytes.
Range: bytes=500-999 specifies the second 500 bytes.
Range: bytes=-500 specifies the last 500 bytes.
Range: bytes=500- specifies data from the 500th byte to the end of the file.
Range: bytes=0- specifies data from the first byte to the last byte, which is the full data of the file.
Download a file by concurrently downloading multiple parts of the file
If you download a large file by downloading the parts of the file in sequence, a large amount of time may be consumed. To improve the download speed, you can send multiple download requests to concurrently download different parts of the file and merge the downloaded parts to obtain the complete file. You must specify the Range header in each download request.
For example, if you want to download a file of 300 MB, you can send three concurrent download requests and each concurrent download request downloads 100 MB data of the file.
Thread 1: Range: bytes=0-104857599
Thread 2: Range: bytes=104857600-209715199
Thread 3: Range: bytes=209715200-314572799

Download a file by using a 302 redirect
You can call the DownloadFile operation to download a file. The download URL is returned together with an HTTP status code 302.
Applicable scenarios:
You want to download a file by using a browser.
You want to download a cached file, such as an image component. However, the obtained download URL of a file varies each time you call the GetDownloadUrl operation. This type of download URL cannot be used to download a cached file. In this case, you can specify the drive_id and file_id parameters and call the DownloadFile operation to download the file. The drive_id and file_id parameters specify the drive ID and the file ID, which remain unchanged for the file. A redirect is performed after you call the DownloadFile operation. Make sure that your application supports redirects.