1
0
Fork 0
mirror of https://github.com/Luzifer/share.git synced 2024-12-20 10:31:16 +00:00

Add support for setting S3 compatible endpoint

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2023-06-05 18:04:36 +02:00
parent f2e3eebbac
commit 3b8e103edd
Signed by: luzifer
GPG key ID: D91C3E91E4CAD6F5
2 changed files with 7 additions and 1 deletions

View file

@ -22,6 +22,7 @@ var (
Bootstrap bool `flag:"bootstrap" default:"false" description:"Upload frontend files into bucket"` Bootstrap bool `flag:"bootstrap" default:"false" description:"Upload frontend files into bucket"`
Bucket string `flag:"bucket" default:"" description:"S3 bucket to upload files to" validate:"nonzero"` Bucket string `flag:"bucket" default:"" description:"S3 bucket to upload files to" validate:"nonzero"`
ContentType string `flag:"content-type,c" default:"" description:"Force content-type to be set to this value"` ContentType string `flag:"content-type,c" default:"" description:"Force content-type to be set to this value"`
Endpoint string `flag:"endpoint" default:"" description:"Override AWS S3 endpoint (i.e. to use MinIO)"`
FileTemplate string `flag:"file-template" vardefault:"file_template" description:"Full name template of the uploaded file"` FileTemplate string `flag:"file-template" vardefault:"file_template" description:"Full name template of the uploaded file"`
Listen string `flag:"listen" default:"" description:"Enable HTTP server if set to IP/Port (e.g. ':3000')"` Listen string `flag:"listen" default:"" description:"Enable HTTP server if set to IP/Port (e.g. ':3000')"`
LogLevel string `flag:"log-level" default:"info" description:"Log level (debug, info, warn, error, fatal)"` LogLevel string `flag:"log-level" default:"info" description:"Log level (debug, info, warn, error, fatal)"`

View file

@ -64,7 +64,12 @@ func executeUpload(inFileName string, inFileHandle io.ReadSeeker, useCalculatedF
contentEncoding = aws.String("gzip") contentEncoding = aws.String("gzip")
} }
sess := session.Must(session.NewSession()) var awsCfgs []*aws.Config
if cfg.Endpoint != "" {
awsCfgs = append(awsCfgs, &aws.Config{Endpoint: &cfg.Endpoint, S3ForcePathStyle: aws.Bool(true)})
}
sess := session.Must(session.NewSession(awsCfgs...))
svc := s3.New(sess) svc := s3.New(sess)
ps, err := newProgressSeeker(inFileHandle) ps, err := newProgressSeeker(inFileHandle)