func (u *S3Uploader) Upload(artifact *Artifact) error {
	// Define the permission to use. Hard coded for now.
	permission := "public-read"
	Perms := s3.ACL(permission)

	Logger.Debugf("Reading file %s", artifact.AbsolutePath)
	data, err := ioutil.ReadFile(artifact.AbsolutePath)
	if err != nil {
		return errors.New("Failed to read file " + artifact.AbsolutePath + " (" + err.Error() + ")")
	}

	Logger.Debugf("Putting to %s with permission %s", u.artifactPath(artifact), permission)
	err = u.Bucket.Put(u.artifactPath(artifact), data, artifact.MimeType(), Perms, s3.Options{})
	if err != nil {
		return errors.New("Failed to PUT file " + u.artifactPath(artifact) + " (" + err.Error() + ")")
	}

	return nil
}
func putLog(t transfer, bucket *s3.Bucket, dry bool) {
	data, err := ioutil.ReadFile(t.Src)
	if err != nil {
		// Error reading log
		log.Printf("Error reading source file %s:\n", t.Src)
		log.Fatal(err)
	}

	contType := "binary/octet-stream"
	perm := s3.ACL("private")

	if dry {
		log.Printf("Starting sync of %s to bucket path %s...\n", t.Src, t.Dest)
	} else {
		log.Printf("Starting sync of %s to s3://%s/%s...\n", t.Src, bucket.Name, t.Dest)
		err = bucket.Put(t.Dest, data, contType, perm, s3.Options{})
		if err != nil {
			// Error uploading log to s3
			log.Printf("Sync of %s to s3://%s/%s failed:\n", t.Src, bucket.Name, t.Dest)
			log.Fatal(err)
		}
	}
}
// PUT on a bucket creates the bucket.
// http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketPUT.html
func (r bucketResource) put(a *action) interface{} {
	var created bool
	if r.bucket == nil {
		if !validBucketName(r.name) {
			fatalf(400, "InvalidBucketName", "The specified bucket is not valid")
		}
		if loc := locationConstraint(a); loc == "" {
			fatalf(400, "InvalidRequets", "The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.")
		}
		// TODO validate acl
		r.bucket = &bucket{
			name: r.name,
			// TODO default acl
			objects: make(map[string]*object),
		}
		a.srv.buckets[r.name] = r.bucket
		created = true
	}
	if !created && a.srv.config.send409Conflict() {
		fatalf(409, "BucketAlreadyOwnedByYou", "Your previous request to create the named bucket succeeded and you already own it.")
	}
	r.bucket.acl = s3.ACL(a.req.Header.Get("x-amz-acl"))
	return nil
}