Remove useless region check
This commit is contained in:
parent
7d304082ea
commit
7ac6cf12c7
|
@ -2,22 +2,22 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/tus/tusd"
|
"github.com/tus/tusd"
|
||||||
"github.com/tus/tusd/filestore"
|
"github.com/tus/tusd/filestore"
|
||||||
"github.com/tus/tusd/limitedstore"
|
"github.com/tus/tusd/limitedstore"
|
||||||
"github.com/tus/tusd/s3store"
|
"github.com/tus/tusd/s3store"
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go/aws/credentials"
|
|
||||||
"github.com/aws/aws-sdk-go/service/s3"
|
|
||||||
"github.com/aws/aws-sdk-go/aws/session"
|
|
||||||
"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/service/s3"
|
||||||
)
|
)
|
||||||
|
|
||||||
var VersionName = "n/a"
|
var VersionName = "n/a"
|
||||||
|
@ -67,18 +67,12 @@ func main() {
|
||||||
|
|
||||||
store = filestore.New(dir)
|
store = filestore.New(dir)
|
||||||
} else {
|
} else {
|
||||||
// Attempt to find location for S3 bucket
|
stdout.Printf("Using 's3://%s' as S3 bucket for storage.\n", s3Bucket)
|
||||||
svc := s3.New(session.New())
|
|
||||||
res, err := svc.GetBucketLocation(&s3.GetBucketLocationInput{
|
|
||||||
Bucket: aws.String(s3Bucket), // Required
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
stderr.Fatalf("Unable to get bucket location: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
region := res.LocationConstraint
|
// Derive credentials from AWS_SECRET_ACCESS_KEY, AWS_ACCESS_KEY_ID and
|
||||||
stdout.Printf("Using 's3://%s' (%s) as S3 bucket for storage.\n", s3Bucket, region)
|
// AWS_REGION environment variables.
|
||||||
store = s3store.New(s3Bucket, s3.New(session.New(), aws.NewConfig().WithCredentials(credentials.NewEnvCredentials())))
|
credentials := aws.NewConfig().WithCredentials(credentials.NewEnvCredentials())
|
||||||
|
store = s3store.New(s3Bucket, s3.New(session.New(), credentials))
|
||||||
}
|
}
|
||||||
|
|
||||||
if storeSize > 0 {
|
if storeSize > 0 {
|
||||||
|
|
Loading…
Reference in New Issue