func()

in dth/client.go [137:166]


func (c *S3Client) GetObject(ctx context.Context, key *string, size, start, chunkSize int64, version string) ([]byte, error) {
	// log.Printf("S3> Downloading %s with %d bytes start from %d\n", key, size, start)
	if size == 0 { // for prefix
		return nil, nil
	}
	bodyRange := fmt.Sprintf("bytes=%d-%d", start, start+chunkSize-1)
	input := &s3.GetObjectInput{
		Bucket: &c.bucket,
		Key:    key,
		Range:  &bodyRange,
	}

	output, err := c.client.GetObject(ctx, input)
	if err != nil {
		log.Printf("S3> Unable to download %s with %d bytes start from %d - %s\n", *key, size, start, err.Error())
		return nil, err
	}

	defer output.Body.Close()

	// Read response body
	s, err := io.ReadAll(output.Body)

	if err != nil {
		log.Printf("S3> Unable to read the content of %s - %s\n", *key, err.Error())
		return nil, err
	}
	return s, nil

}