mardi 5 mai 2015

Saving file to S3 using aws-sdk-go

I'm having a bit of trouble saving a file in golang with the AWS S3 go sdk (http://ift.tt/1DkIrwL).

This is what I have:

import (
        "fmt"
        "bytes"

        "http://ift.tt/1FMX2me"
        "http://ift.tt/1FOYv9x"
        "http://ift.tt/1DQRWBI"
)

func main() {    
    cred := aws.DefaultChainCredentials
    cred.Get() // i'm using environment variable credentials and yes, I checked if they were in here
    svc := s3.New(&aws.Config{Region: "us-west-2", Credentials:cred, LogLevel: 1})
    params := &s3.PutObjectInput{
                    Bucket:         aws.String("my-bucket-123"),
                    Key:            aws.String("test/123/"),
                    Body:         bytes.NewReader([]byte("testing!")),
            }
    resp, err := svc.PutObject(params)
    fmt.Printf("response %s", awsutil.StringValue(resp))
}

I keep receiving a 301 Moved Permanently Response.




Aucun commentaire:

Enregistrer un commentaire