How do I download a large object?

Updated at:

You may fail to download a large object if the network is unstable or other exceptions occur. In some cases, you may still fail to download the object even after multiple attempts. We recommend that you use OSS SDKs or ossutil to download a large object.

Use OSS SDKs

You can use OSS SDKs to perform resumable download of large objects. Take note of the following items when you perform resumable download:

  • In this topic, the public endpoint of the China (Hangzhou) region is used. If you want to access OSS from other Alibaba Cloud services in the same region as OSS, use an internal endpoint. For more information about OSS regions and endpoints, see Regions and endpoints.

  • In this topic, access credentials are obtained from environment variables. For more information about how to configure access credentials, see Configure access credentials.

  • This topic demonstrates creating an OSSClient instance with an OSS endpoint. For alternative configurations, such as using a custom domain or authenticating with credentials from Security Token Service (STS), see Configure a client (Go SDK V1).

  • To use resumable download, you must have the oss:GetObject permission. For more information, see Grant a custom policy.

  • During resumable download, the download progress is recorded in a checkpoint file. If a part fails to be downloaded, the next download starts from the position that is recorded in the checkpoint file. The checkpoint file is deleted after resumable download is complete.

  • OSS SDK for Go records the download progress in the checkpoint file. Make sure that you have write permissions on the checkpoint file.

  • You cannot modify the checksum that is contained in the checkpoint file. If the checkpoint file is damaged, you need to download all parts again.

  • If the ETag of the object is not consistent or parts are lost or modified during the download, you need to download the object again.

For more information about the code for resumable download, see Use OSS SDKs.

Use ossutil

You can run the cp command in the ossutil tool to download a large object.

For more information, see cp (download files).