svc := s3.New(session.New()) params := &s3.CreateBucketInput{ Bucket: aws.String("my-bucket"), } _, err := svc.CreateBucket(params) if err != nil { fmt.Println(err) }
file, err := os.Open("myfile.txt") if err != nil { fmt.Println(err) return } defer file.Close() svc := s3.New(session.New()) params := &s3.PutObjectInput{ Body: file, Bucket: aws.String("my-bucket"), Key: aws.String("myfile.txt"), } _, err = svc.PutObject(params) if err != nil { fmt.Println(err) }
svc := s3.New(session.New()) params := &s3.ListObjectsInput{ Bucket: aws.String("my-bucket"), } resp, err := svc.ListObjects(params) if err != nil { fmt.Println(err) return } for _, obj := range resp.Contents { fmt.Println(*obj.Key) }These examples demonstrate some of the basic functionality provided by the `github.com/aws/aws-sdk-go/service/s3` package.