コード例 #1
0
ファイル: bucket_opers.go プロジェクト: marcelom/GoAWS
// 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)),
	}
}