Generate data for large random file


(Rob Marshall) #1

Hi,

I want to be able to feed random data to S3 to create a large multipart uploaded object. I don’t have, or at least may not have, enough disk space to create the file in the local filesystem so I’d like to be able to do something like setup a way to read, e.g. from /dev/urandom, or generate random data X bytes at a time until I reach the desired file size.

Any suggestions?

Thanks,

Rob


(Jakob Borg) #2

The crypto/rand package has a Reader for this purpose: https://golang.org/pkg/crypto/rand/#pkg-variables

Combine that with a LimitedReader and it can be you upload body.


(Rob Marshall) #3

Thank-you. I’ll take a look at it. It appears that rand reads from /dev/urandom, so it should give me something similar to what I’m doing with Python.

Rob