diff --git a/cmd/tusd/cli/composer.go b/cmd/tusd/cli/composer.go index 6b0239a..71a410f 100644 --- a/cmd/tusd/cli/composer.go +++ b/cmd/tusd/cli/composer.go @@ -26,8 +26,18 @@ func CreateComposer() { if Flags.S3Bucket != "" { s3Config := aws.NewConfig() + if Flags.S3TransferAcceleration { + s3Config = s3Config.WithS3UseAccelerate(true) + } + if Flags.S3Endpoint == "" { - stdout.Printf("Using 's3://%s' as S3 bucket for storage.\n", Flags.S3Bucket) + + if Flags.S3TransferAcceleration { + stdout.Printf("Using 's3://%s' as S3 bucket for storage with AWS S3 Transfer Acceleration enabled.\n", Flags.S3Bucket) + } else { + stdout.Printf("Using 's3://%s' as S3 bucket for storage.\n", Flags.S3Bucket) + } + } else { stdout.Printf("Using '%s/%s' as S3 endpoint and bucket for storage.\n", Flags.S3Endpoint, Flags.S3Bucket) diff --git a/cmd/tusd/cli/flags.go b/cmd/tusd/cli/flags.go index 1e0ae91..67e8e00 100644 --- a/cmd/tusd/cli/flags.go +++ b/cmd/tusd/cli/flags.go @@ -39,6 +39,7 @@ var Flags struct { MetricsPath string BehindProxy bool VerboseOutput bool + S3TransferAcceleration bool } func ParseFlags() { @@ -71,6 +72,7 @@ func ParseFlags() { flag.StringVar(&Flags.MetricsPath, "metrics-path", "/metrics", "Path under which the metrics endpoint will be accessible") flag.BoolVar(&Flags.BehindProxy, "behind-proxy", false, "Respect X-Forwarded-* and similar headers which may be set by proxies") flag.BoolVar(&Flags.VerboseOutput, "verbose", true, "Enable verbose logging output") + flag.BoolVar(&Flags.S3TransferAcceleration, "s3-transfer-acceleration", false, "Use AWS S3 transfer acceleration endpoint (requires -s3-bucket option and Transfer Acceleration property on S3 bucket to be set)") flag.Parse() SetEnabledHooks() diff --git a/docs/usage-binary.md b/docs/usage-binary.md index 8b32aa7..aab4a69 100644 --- a/docs/usage-binary.md +++ b/docs/usage-binary.md @@ -34,7 +34,26 @@ $ tusd -s3-bucket=my-test-bucket.com [tusd] 2019/09/29 21:11:23 You can now upload files to: http://0.0.0.0:1080/files/ ``` +If your S3 bucket has been configured for AWS S3 Transfer Acceleration and you want to make use of that advanced service, +you can direct tusd to automatically use the designated AWS acceleration endpoint for your bucket by including the optional +command line flag `s3-transfer-acceleration` as follows: + +``` +$ export AWS_ACCESS_KEY_ID=xxxxx +$ export AWS_SECRET_ACCESS_KEY=xxxxx +$ export AWS_REGION=eu-west-1 +$ tusd -s3-bucket=my-test-bucket.com -s3-transfer-acceleration +[tusd] 2019/09/29 21:11:23 Using 's3://my-test-bucket.com' as S3 bucket for storage with AWS S3 Transfer Acceleration enabled. +[tusd] 2019/09/29 21:11:23 Using 0.00MB as maximum size. +[tusd] 2019/09/29 21:11:23 Using 0.0.0.0:1080 as address to listen. +[tusd] 2019/09/29 21:11:23 Using /files/ as the base path. +[tusd] 2019/09/29 21:11:23 Using /metrics as the metrics path. +[tusd] 2019/09/29 21:11:23 Supported tus extensions: creation,creation-with-upload,termination,concatenation,creation-defer-length +[tusd] 2019/09/29 21:11:23 You can now upload files to: http://0.0.0.0:1080/files/ +``` + tusd is also able to read the credentials automatically from a shared credentials file (~/.aws/credentials) as described in https://github.com/aws/aws-sdk-go#configuring-credentials. +But be mindful of the need to declare the AWS_REGION value which isn't conventionally associated with credentials. Furthermore, tusd also has support for storing uploads on Google Cloud Storage. In order to enable this feature, supply the path to your account file containing the necessary credentials: