title: Saving file to S3 using aws-sdk-go
body: <p>I'm having a bit of trouble saving a file in golang with the AWS S3 go sdk (<a href="https://github.com/awslabs/aws-sdk-go" rel="nofollow">https://github.com/awslabs/aws-sdk-go</a>). </p>
  
  <p>This is what I have:</p>
  
  <pre><code>import (
          "fmt"
          "bytes"
  
          "github.com/awslabs/aws-sdk-go/aws"
          "github.com/awslabs/aws-sdk-go/aws/awsutil"
          "github.com/awslabs/aws-sdk-go/service/s3"
  )
  
  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(&amp;aws.Config{Region: "us-west-2", Credentials:cred, LogLevel: 1})
      params := &amp;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))
  }
  </code></pre>
  
  <p>I keep receiving a <code>301 Moved Permanently</code> response. </p>
  
  <p>Edit: I created the bucket manually.
  Edit #2: Example response:</p>
  
  <pre><code>---[ RESPONSE ]--------------------------------------
  HTTP/1.1 301 Moved Permanently
  Transfer-Encoding: chunked
  Content-Type: application/xml
  Date: Tue, 05 May 2015 18:42:03 GMT
  Server: AmazonS3
  </code></pre>
  
  <p>POST sign is http as well.</p>