예제 #1
0
// NewBucket creates a new *Bucket object from an endpoint URL.
//
// URL is the _endpoint_ url (nil will default to https://s3.amazonaws.com/)
// Name should be the bucket name; If you pass this as an empty string, you will regret it.
// conn is OPTIONAL, but allows you to re-use another aws.Conn if you'd like.
//
// If you omit conn, the dialer used will be based off the VHost of your bucket (if possible),
// to ensure best performance (e.g., endpoint associated w/ your bucket, and any
// regional lb's)
func NewBucket(u *http.URL, Name string, conn *aws.Conn) (b *Bucket) {
	if u == nil {
		u = &http.URL{Scheme: "https", Host: USEAST_HOST, Path: "/"}
	}
	if conn == nil {
		vname := VhostName(Name, u)
		addrs, err := net.LookupHost(vname)
		if err == nil && len(addrs) > 0 {
			dial_url := &http.URL{
				Scheme: u.Scheme,
				Host:   vname,
				Path:   u.Path,
			}
			conn = aws.NewConn(aws.URLDialer(dial_url, nil))
		} else {
			conn = aws.NewConn(aws.URLDialer(u, nil))
		}
	}
	b = &Bucket{
		URL:  u,
		Name: Name,
		conn: conn,
	}
	return
}
예제 #2
0
파일: service.go 프로젝트: abneptis/GoAWS
func NewService(url *http.URL) *Service {
	return &Service{
		URL:  url,
		conn: aws.NewConn(aws.URLDialer(url, nil)),
	}
}
예제 #3
0
파일: queue.go 프로젝트: justinbarry/GoAWS
func NewQueue(url *http.URL) *Queue {
	return &Queue{
		URL:  url,
		conn: aws.NewConn(aws.URLDialer(url, nil)),
	}
}