I'm using the Goamz package and could use some help getting bucket.Multi to stream an HTTP GET response to S3.
I'll be downloading a 2+ GB file via chunked HTTP and I'd like to stream it directly into an S3 bucket.
It appears that I need to wrap the resp.Body with something so I can pass an implementation of s3.ReaderAtSeeker to multi.PutAll
// set up s3
auth, _ := aws.EnvAuth()
s3Con := s3.New(auth, aws.USEast)
bucket := s3Con.Bucket("bucket-name")
// make http request to URL
resp, err := http.Get(export_url)
if err != nil {
fmt.Printf("Get error %v\n", err)
return
}
defer resp.Body.Close()
// set up multi-part
multi, err := bucket.InitMulti(s3Path, "text/plain", s3.Private, s3.Options{})
if err != nil {
fmt.Printf("InitMulti error %v\n", err)
return
}
// Need struct that implements: s3.ReaderAtSeeker
// type ReaderAtSeeker interface {
// io.ReaderAt
// io.ReadSeeker
// }
rs := // Question: what can i wrap `resp.Body` in?
parts, err := multi.PutAll(rs, 5120)
if err != nil {
fmt.Printf("PutAll error %v\n", err)
return
}
err = multi.Complete(parts)
if err != nil {
fmt.Printf("Complete error %v\n", err)
return
}
Currently I get the following (expected) error when trying to run my program:
./main.go:50: cannot use resp.Body (type io.ReadCloser) as type s3.ReaderAtSeeker in argument to multi.PutAll:
io.ReadCloser does not implement s3.ReaderAtSeeker (missing ReadAt method)