Download objects using OSS SDK for Go 2.0

Updated at:
Copy as MD

OSS SDK for Go V2 provides multiple download methods. Choose one based on your use case.

Type

Operation

Description

Simple download

Client.GetObject

  • Streaming download. Response body type: io.ReadCloser.

  • No CRC-64.

  • No built-in progress bar.

  • No reconnection during streaming read.

Client.GetObjectToFile

  • Saves objects to local files.

  • Single-connection download.

  • CRC-64 enabled by default.

  • Progress bar supported.

  • Reconnection on failure.

Range download

Client.GetObject

  • Downloads a specific byte range of an object.

File-Like operations

ReadOnlyFile

ReadOnlyFile.Read

ReadOnlyFile.Seek

ReadOnlyFile.Close

  • Implements io.Reader, io.Seeker, and io.Closer interfaces.

  • Supports random access via Seek.

  • Single-stream mode (default).

  • Asynchronous prefetch mode for faster reads.

  • Configurable prefetch block size and chunk count.

  • No CRC-64.

  • No built-in progress bar.

  • Reconnection on failure.

A signed URL

Client.Presign

  • Generates a time-limited signed URL for downloading an object via HTTP GET.

Downloader

Downloader.DownloadFile

  • Multipart download to local files.

  • Configurable part size and parallelism.

  • CRC-64 enabled by default.

  • Progress bar supported.

  • Reconnection on failure.

  • Resumable download.

  • Downloads to a temporary object, then renames it (enabled by default). Configurable.