我正在使用amazon s3 sdk下载文件,如下所示:
file, err := os.Create("/tmp/download_file") downloader := s3manager.NewDownloader(session.New(&aws.Config{ Region: aws.String("us-west-2")})) numBytes, err := downloader.Download(file, &s3.GetObjectInput{ Bucket: aws.String(bucketName), Key: aws.String(fileName), })
它下载到一个文件.如何直接将下载内容导入[]字节片(缓冲区).我试过类似的东西
var tBuf bytes.Buffer tBufIo := bufio.NewWriter(&tBuf)
而不是"文件".但是为io.WriterAt接口获取错误
file, err := os.Create("/tmp/download_file") downloader := s3manager.NewDownloader(session.New(&aws.Config{ Region: aws.String("us-west-2")})) numBytes, err := downloader.Download(file, &s3.GetObjectInput{ Bucket: aws.String(bucketName), Key: aws.String(fileName), })
sriba.. 18
通过链接https://groups.google.com/forum/#!topic/Golang-Nuts/4z8rcWEZ8Os找到它
buff := &aws.WriteAtBuffer{} downloader := s3manager.NewDownloader(session.New(&aws.Config{ Region: aws.String(S3_Region)})) numBytes, err := downloader.Download(buff,.... data := buff.Bytes() // now data is my []byte array
适用并满足需求.
通过链接https://groups.google.com/forum/#!topic/Golang-Nuts/4z8rcWEZ8Os找到它
buff := &aws.WriteAtBuffer{} downloader := s3manager.NewDownloader(session.New(&aws.Config{ Region: aws.String(S3_Region)})) numBytes, err := downloader.Download(buff,.... data := buff.Bytes() // now data is my []byte array
适用并满足需求.