Add hostname
This commit is contained in:
+1
-1
@@ -40,7 +40,7 @@ func doGetObject(c *cli.Context) {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
s3c := s3.NewS3Client(accessKey, secretKey)
|
||||
s3c := s3.NewS3Client(accessKey, secretKey, "s3.amazonaws.com")
|
||||
objectReader, objectSize, err = s3c.Get(bucket, key)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ func doListObjects(c *cli.Context) {
|
||||
}
|
||||
|
||||
var items []*s3.Item
|
||||
s3c := s3.NewS3Client(accessKey, secretKey)
|
||||
s3c := s3.NewS3Client(accessKey, secretKey, "s3.amazonaws.com")
|
||||
// Gets 1000 maxkeys supported with GET Bucket API
|
||||
items, err = s3c.GetBucket(bucket, "", s3.MAX_OBJECT_LIST)
|
||||
if err != nil {
|
||||
|
||||
+8
-2
@@ -347,8 +347,14 @@ func (c *Client) Delete(bucket, key string) error {
|
||||
return fmt.Errorf("Amazon HTTP error on DELETE: %d", res.StatusCode)
|
||||
}
|
||||
|
||||
func NewS3Client(accessKey, secretKey string) *Client {
|
||||
return &Client{&Auth{AccessKey: accessKey, SecretAccessKey: secretKey}, http.DefaultTransport}
|
||||
func NewS3Client(accessKey, secretKey, hostname string) (client *Client) {
|
||||
client = &Client{
|
||||
&Auth{
|
||||
AccessKey: accessKey,
|
||||
SecretAccessKey: secretKey,
|
||||
Hostname: hostname},
|
||||
http.DefaultTransport}
|
||||
return
|
||||
}
|
||||
|
||||
// IsValid reports whether bucket is a valid bucket name, per Amazon's naming restrictions.
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ func doPutObject(c *cli.Context) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
s3c := s3.NewS3Client(accessKey, secretKey)
|
||||
s3c := s3.NewS3Client(accessKey, secretKey, "s3.amazonaws.com")
|
||||
var bodyFile *os.File
|
||||
bodyFile, err = os.Open(body)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user