Baidu AI Cloud
中国站

百度智能云

Object Storage

Breakpoint Resume Download

Basic Introduction

BOS provides the function of downloading from the location specified by the object. When downloading a large object, it can be downloaded several times. If the download is interrupted, the download can also continue from the last completed location when restarting.

It is similar to a simple upload, you also need to have read access to the object. Breakpoint continuation is supported by setting the parameter Range, which is recommended for larger objects. The definition of Range can be found in the HTTP RFC. If the Range parameter is used in the request header, the return message will contain the length of the entire file and the range returned this time. E.g.: Content-Range: bytes 0-9/44, which means the length of the entire file is 44, and the range returned this time is 0-9.

Note

  • For object with a Range size of 0 byte, 400 error is returned, and Range is the front-closed back-closed interval.
  • Archive storage type objects need to be retrieved before the GetObject interface can be called.

Operation Method

Example

Taking the Java SDK as an example, by using GetObjectRequest to specify the download scope, we can obtain objects more accurately. If the specified download range is 0-100, the 0-100th (including) byte of data is returned, 101 bytes of data in total, i.e. [0, 100].

// Create a GetObjectRequest
GetObjectRequest getObjectRequest = new GetObjectRequest(bucketName, objectKey);

// Get data in the range of 0-100 bytes
getObjectRequest.setRange(0, 100);

// Get object and return BosObject
BosObject object = client.getObject(getObjectRequest);

With the setRange method of getObjectRequest, it is only possible to set the range of returned object. You can use this function for segmented download of file and breakpoint continued upload.

Previous
Simple Download
Next
Data Use and Management