SDK aws S3 Download to stdout

369 views
Skip to first unread message

wal...@gmail.com

unread,
Jun 29, 2016, 6:35:31 PM6/29/16
to golang-dev
Hello all.

Im new using AWS SDK in go and Im need download file object from S3 to Stdout and not create a file.
For example:
my_download_s3_program > file.txt
or
my_download_s3_program | tar
etc

So, I can download to file, but I need stream on the fly to stdout, it's possible?

This example write a file:
----------------------------------------------------------------------
            file, err := os.Create("download_file.txt")
            if err != nil {
                fmt.Println("Failed to create file", err)
                os.Exit(4)
            }
            defer file.Close()

            key := path.Join(prefix, filename)

            downloader := s3manager.NewDownloader(session.New(&aws.Config{Region: aws.String("us-west-2")}))
            numBytes, err := downloader.Download(f,
                &s3.GetObjectInput{
                    Bucket: aws.String(bucket),
                    Key:    aws.String(key),
                })
            if err != nil {
                fmt.Println("Failed to download file", err)
                os.Exit(5)
            }

            fmt.Println("Downloaded file", file.Name(), numBytes, "bytes")

----------------------------------------------------------------------

How can modify this example to stream to stdout?

Well, thanks in advance.

Benny Siegert

unread,
Jun 30, 2016, 7:48:27 AM6/30/16
to wal...@gmail.com, golang-dev
This question belongs on golang-nuts, not golang-dev. This list is only for development of Go itself.

--
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages