Created
October 11, 2018 04:07
-
-
Save pindlebot/7e1acea60e0de6fc204fc60e36e8a4b8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "bytes" | |
| "fmt" | |
| "strings" | |
| "github.com/aws/aws-sdk-go/aws" | |
| "github.com/aws/aws-sdk-go/aws/endpoints" | |
| "github.com/aws/aws-sdk-go/aws/session" | |
| "github.com/aws/aws-sdk-go/service/s3" | |
| ) | |
| func putObject() { | |
| sess := session.Must(session.NewSession(&aws.Config{ | |
| Region: aws.String(endpoints.UsEast1RegionID), | |
| })) | |
| svc := s3.New(sess) | |
| _, err := svc.PutObject(&s3.PutObjectInput{ | |
| Bucket: aws.String("documentqueue"), | |
| Key: aws.String("lorem.txt"), | |
| Body: aws.ReadSeekCloser(strings.NewReader("lorem")), | |
| }) | |
| if err != nil { | |
| panic(err) | |
| } | |
| } | |
| func getObject() { | |
| sess := session.Must(session.NewSession(&aws.Config{ | |
| Region: aws.String(endpoints.UsEast1RegionID), | |
| })) | |
| svc := s3.New(sess) | |
| result, err := svc.GetObject(&s3.GetObjectInput{ | |
| Bucket: aws.String("documentqueue"), | |
| Key: aws.String("lorem.txt"), | |
| }) | |
| if err != nil { | |
| panic(err) | |
| } | |
| buf := new(bytes.Buffer) | |
| buf.ReadFrom(result.Body) | |
| str := buf.String() | |
| return str | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment