Add support for S3 path style URLS.tags/v1.1.1
@@ -165,6 +165,7 @@ aws-secret-key | aws access key | | AWS_SECRET_KEY | |||||
bucket | aws bucket | | BUCKET | bucket | aws bucket | | BUCKET | ||||
s3-region | region of the s3 bucket | eu-west-1 | S3_REGION | s3-region | region of the s3 bucket | eu-west-1 | S3_REGION | ||||
s3-no-multipart | disables s3 multipart upload | false | | | s3-no-multipart | disables s3 multipart upload | false | | | ||||
s3-path-style | Forces path style URLs, required for Minio. | false | | | |||||
basedir | path storage for local/gdrive provider| | | basedir | path storage for local/gdrive provider| | | ||||
gdrive-client-json-filepath | path to oauth client json config for gdrive provider| | | gdrive-client-json-filepath | path to oauth client json config for gdrive provider| | | ||||
gdrive-local-config-path | path to store local transfer.sh config cache for gdrive provider| | | gdrive-local-config-path | path to store local transfer.sh config cache for gdrive provider| | | ||||
@@ -130,6 +130,10 @@ var globalFlags = []cli.Flag{ | |||||
Name: "s3-no-multipart", | Name: "s3-no-multipart", | ||||
Usage: "Disables S3 Multipart Puts", | Usage: "Disables S3 Multipart Puts", | ||||
}, | }, | ||||
cli.BoolFlag{ | |||||
Name: "s3-path-style", | |||||
Usage: "Forces path style URLs, required for Minio.", | |||||
}, | |||||
cli.StringFlag{ | cli.StringFlag{ | ||||
Name: "gdrive-client-json-filepath", | Name: "gdrive-client-json-filepath", | ||||
Usage: "", | Usage: "", | ||||
@@ -339,7 +343,7 @@ func New() *Cmd { | |||||
panic("secret-key not set.") | panic("secret-key not set.") | ||||
} else if bucket := c.String("bucket"); bucket == "" { | } else if bucket := c.String("bucket"); bucket == "" { | ||||
panic("bucket not set.") | panic("bucket not set.") | ||||
} else if storage, err := server.NewS3Storage(accessKey, secretKey, bucket, c.String("s3-region"), c.String("s3-endpoint"), logger, c.Bool("s3-no-multipart")); err != nil { | |||||
} else if storage, err := server.NewS3Storage(accessKey, secretKey, bucket, c.String("s3-region"), c.String("s3-endpoint"), logger, c.Bool("s3-no-multipart"), c.Bool("s3-path-style")); err != nil { | |||||
panic(err) | panic(err) | ||||
} else { | } else { | ||||
options = append(options, server.UseStorage(storage)) | options = append(options, server.UseStorage(storage)) | ||||
@@ -3,10 +3,6 @@ package server | |||||
import ( | import ( | ||||
"encoding/json" | "encoding/json" | ||||
"fmt" | "fmt" | ||||
"github.com/aws/aws-sdk-go/aws" | |||||
"github.com/aws/aws-sdk-go/aws/awserr" | |||||
"github.com/aws/aws-sdk-go/aws/session" | |||||
"github.com/aws/aws-sdk-go/service/s3/s3manager" | |||||
"io" | "io" | ||||
"io/ioutil" | "io/ioutil" | ||||
"log" | "log" | ||||
@@ -16,7 +12,11 @@ import ( | |||||
"path/filepath" | "path/filepath" | ||||
"strings" | "strings" | ||||
"github.com/aws/aws-sdk-go/aws" | |||||
"github.com/aws/aws-sdk-go/aws/awserr" | |||||
"github.com/aws/aws-sdk-go/aws/session" | |||||
"github.com/aws/aws-sdk-go/service/s3" | "github.com/aws/aws-sdk-go/service/s3" | ||||
"github.com/aws/aws-sdk-go/service/s3/s3manager" | |||||
"golang.org/x/net/context" | "golang.org/x/net/context" | ||||
"golang.org/x/oauth2" | "golang.org/x/oauth2" | ||||
"golang.org/x/oauth2/google" | "golang.org/x/oauth2/google" | ||||
@@ -132,8 +132,8 @@ type S3Storage struct { | |||||
noMultipart bool | noMultipart bool | ||||
} | } | ||||
func NewS3Storage(accessKey, secretKey, bucketName, region, endpoint string, logger *log.Logger, disableMultipart bool) (*S3Storage, error) { | |||||
sess := getAwsSession(accessKey, secretKey, region, endpoint) | |||||
func NewS3Storage(accessKey, secretKey, bucketName, region, endpoint string, logger *log.Logger, disableMultipart bool, forcePathStyle bool) (*S3Storage, error) { | |||||
sess := getAwsSession(accessKey, secretKey, region, endpoint, forcePathStyle) | |||||
return &S3Storage{bucket: bucketName, s3: s3.New(sess), session: sess, logger: logger, noMultipart: disableMultipart}, nil | return &S3Storage{bucket: bucketName, s3: s3.New(sess), session: sess, logger: logger, noMultipart: disableMultipart}, nil | ||||
} | } | ||||
@@ -25,7 +25,6 @@ THE SOFTWARE. | |||||
package server | package server | ||||
import ( | import ( | ||||
"github.com/aws/aws-sdk-go/aws/credentials" | |||||
"math" | "math" | ||||
"net/http" | "net/http" | ||||
"net/mail" | "net/mail" | ||||
@@ -33,15 +32,17 @@ import ( | |||||
"strings" | "strings" | ||||
"github.com/aws/aws-sdk-go/aws" | "github.com/aws/aws-sdk-go/aws" | ||||
"github.com/aws/aws-sdk-go/aws/credentials" | |||||
"github.com/aws/aws-sdk-go/aws/session" | "github.com/aws/aws-sdk-go/aws/session" | ||||
"github.com/golang/gddo/httputil/header" | "github.com/golang/gddo/httputil/header" | ||||
) | ) | ||||
func getAwsSession(accessKey, secretKey, region, endpoint string) *session.Session { | |||||
func getAwsSession(accessKey, secretKey, region, endpoint string, forcePathStyle bool) *session.Session { | |||||
return session.Must(session.NewSession(&aws.Config{ | return session.Must(session.NewSession(&aws.Config{ | ||||
Region: aws.String(region), | |||||
Endpoint: aws.String(endpoint), | |||||
Credentials: credentials.NewStaticCredentials(accessKey, secretKey, ""), | |||||
Region: aws.String(region), | |||||
Endpoint: aws.String(endpoint), | |||||
Credentials: credentials.NewStaticCredentials(accessKey, secretKey, ""), | |||||
S3ForcePathStyle: aws.Bool(forcePathStyle), | |||||
})) | })) | ||||
} | } | ||||