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 that. Right now I'm creating a file which implements io.WriterAt but I'd like something in memory.
相关问题
- Golang mongodb aggregation
- How to flatten out a nested json structure in go
- how to install private repo using glide golang
- Assume/switch role in aws toolkit for eclipse 2.0
- How to convert a string to a byte array which is c
Faking AWS WriterAt with an io.Writer
This isn't a direct answer to the original question but rather the solution I actually used after landing here. It's a similar use case that I figure may help others.
The AWS documentation defines the contract such that if you set
downloader.Concurrency
to 1, you get guaranteed sequential writes.Therefore you can take an
io.Writer
and wrap it to fulfill theio.WriterAt
, throwing away theoffset
that you no longer need:I don't know of any way to do this in the standard library, but you can write your own buffer.
It really wouldn't be all that hard...
EDIT: I couldn't stop thinking about this, and I ended up acidentally the whole thing, enjoy :)
For cases involving the AWS SDK, use
aws.WriteAtBuffer
to download S3 objects into memory.