Buffer implementing io.WriterAt in go

后端 未结 3 1065
谎友^
谎友^ 2020-12-09 16:43

I\'m using the aws-sdk to download a file from an s3 bucket. The S3 download function want\'s something that implements io.WriterAt however bytes.Buffer doesn\'t implement t

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-09 17:30

    For cases involving the AWS SDK, use aws.WriteAtBuffer to download S3 objects into memory.

    requestInput := s3.GetObjectInput{
        Bucket: aws.String(bucket),
        Key:    aws.String(key),
    }
    
    buf := aws.NewWriteAtBuffer([]byte{})
    downloader.Download(buf, &requestInput)
    
    fmt.Printf("Downloaded %v bytes", len(buf.Bytes()))
    

提交回复
热议问题