mirror of
https://github.com/dutchcoders/transfer.sh.git
synced 2024-11-26 22:20:18 +01:00
Merge pull request #244 from computeralex92/ISSUE-242
Fix SSL and make change of region possible
This commit is contained in:
commit
cc1a1b8487
5 changed files with 29 additions and 6 deletions
|
@ -18,6 +18,7 @@ FROM scratch AS final
|
|||
LABEL maintainer="Andrea Spacca <andrea.spacca@gmail.com>"
|
||||
|
||||
COPY --from=build /go/bin/transfersh /go/bin/transfersh
|
||||
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||||
|
||||
ENTRYPOINT ["/go/bin/transfersh", "--listener", ":8080"]
|
||||
|
||||
|
|
16
README.md
16
README.md
|
@ -163,6 +163,7 @@ provider | which storage provider to use | (s3, grdrive or local) |
|
|||
aws-access-key | aws access key | | AWS_ACCESS_KEY
|
||||
aws-secret-key | aws access key | | AWS_SECRET_KEY
|
||||
bucket | aws bucket | | BUCKET
|
||||
s3-region | region of the s3 bucket | eu-west-1 | S3_REGION
|
||||
s3-no-multipart | disables s3 multipart upload | false | |
|
||||
basedir | path storage for local/gdrive provider| |
|
||||
gdrive-client-json-filepath | path to oauth client json config for gdrive provider| |
|
||||
|
@ -202,6 +203,21 @@ For easy deployment, we've created a Docker container.
|
|||
docker run --publish 8080:8080 dutchcoders/transfer.sh:latest --provider local --basedir /tmp/
|
||||
```
|
||||
|
||||
## S3 Usage
|
||||
|
||||
For the usage with a AWS S3 Bucket, you just need to specify the following options:
|
||||
- provider
|
||||
- aws-access-key
|
||||
- aws-secret-key
|
||||
- bucket
|
||||
- s3-region
|
||||
|
||||
If you specify the s3-region, you don't need to set the endpoint URL since the correct endpoint will used automatically.
|
||||
|
||||
### Custom S3 providers
|
||||
|
||||
To use a custom non-AWS S3 provider, you need to specify the endpoint as definied from your cloud provider.
|
||||
|
||||
## Contributions
|
||||
|
||||
Contributions are welcome.
|
||||
|
|
10
cmd/cmd.go
10
cmd/cmd.go
|
@ -99,9 +99,15 @@ var globalFlags = []cli.Flag{
|
|||
cli.StringFlag{
|
||||
Name: "s3-endpoint",
|
||||
Usage: "",
|
||||
Value: "http://s3-eu-west-1.amazonaws.com",
|
||||
Value: "",
|
||||
EnvVar: "S3_ENDPOINT",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "s3-region",
|
||||
Usage: "",
|
||||
Value: "eu-west-1",
|
||||
EnvVar: "S3_REGION",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "aws-access-key",
|
||||
Usage: "",
|
||||
|
@ -332,7 +338,7 @@ func New() *Cmd {
|
|||
panic("secret-key not set.")
|
||||
} else if bucket := c.String("bucket"); bucket == "" {
|
||||
panic("bucket not set.")
|
||||
} else if storage, err := server.NewS3Storage(accessKey, secretKey, bucket, c.String("s3-endpoint"), logger, c.Bool("s3-no-multipart")); err != nil {
|
||||
} else if storage, err := server.NewS3Storage(accessKey, secretKey, bucket, c.String("s3-endpoint"), logger, c.Bool("s3-no-multipart"), c.String("s3-region")); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
options = append(options, server.UseStorage(storage))
|
||||
|
|
|
@ -132,8 +132,8 @@ type S3Storage struct {
|
|||
noMultipart bool
|
||||
}
|
||||
|
||||
func NewS3Storage(accessKey, secretKey, bucketName, endpoint string, logger *log.Logger, disableMultipart bool) (*S3Storage, error) {
|
||||
sess := getAwsSession(accessKey, secretKey, endpoint)
|
||||
func NewS3Storage(accessKey, secretKey, bucketName, endpoint string, logger *log.Logger, disableMultipart bool, region string) (*S3Storage, error) {
|
||||
sess := getAwsSession(accessKey, secretKey, endpoint, region)
|
||||
|
||||
return &S3Storage{bucket: bucketName, s3: s3.New(sess), session: sess, logger: logger, noMultipart: disableMultipart}, nil
|
||||
}
|
||||
|
|
|
@ -37,9 +37,9 @@ import (
|
|||
"github.com/golang/gddo/httputil/header"
|
||||
)
|
||||
|
||||
func getAwsSession(accessKey, secretKey, endpoint string) *session.Session {
|
||||
func getAwsSession(accessKey, secretKey, endpoint string, region string) *session.Session {
|
||||
return session.Must(session.NewSession(&aws.Config{
|
||||
Region: aws.String("eu-west-1"),
|
||||
Region: aws.String(region),
|
||||
Endpoint: aws.String(endpoint),
|
||||
Credentials: credentials.NewStaticCredentials(accessKey, secretKey, ""),
|
||||
}))
|
||||
|
|
Loading…
Reference in a new issue