MCPcopy Create free account
hub / github.com/apecloud/myduckserver / DownloadFile

Method DownloadFile

storage/object_storage_client.go:68–89  ·  view source on GitHub ↗
(ctx context.Context, bucketName string, objectKey string, fileName string)

Source from the content-addressed store, hash-verified

66}
67
68func (basics *Bucket) DownloadFile(ctx context.Context, bucketName string, objectKey string, fileName string) (*int64, error) {
69 f, err := os.Create(fileName)
70 if err != nil {
71 return nil, fmt.Errorf("failed to create file %q, %v", fileName, err)
72 }
73 defer f.Close()
74
75 downloader := manager.NewDownloader(basics.S3Client, func(u *manager.Downloader) {
76 u.PartSize = downloadPartSize
77 })
78
79 numBytes, err := downloader.Download(ctx, f, &s3.GetObjectInput{
80 Bucket: aws.String(bucketName),
81 Key: aws.String(objectKey),
82 })
83
84 if err != nil {
85 return nil, fmt.Errorf("failed to download file, %v", err)
86 }
87
88 return &numBytes, nil
89}

Callers 3

DownloadFileMethod · 0.95
executeRestoreMethod · 0.45
ExecuteRestoreFunction · 0.45

Calls 2

CloseMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected