support unofficial S3 regions
Adds support for S3 clones like Ceph.
Этот коммит содержится в:
18
api/file.go
18
api/file.go
@@ -538,7 +538,7 @@ func writeFile(f []byte, path string) *model.AppError {
|
|||||||
auth.AccessKey = utils.Cfg.FileSettings.AmazonS3AccessKeyId
|
auth.AccessKey = utils.Cfg.FileSettings.AmazonS3AccessKeyId
|
||||||
auth.SecretKey = utils.Cfg.FileSettings.AmazonS3SecretAccessKey
|
auth.SecretKey = utils.Cfg.FileSettings.AmazonS3SecretAccessKey
|
||||||
|
|
||||||
s := s3.New(auth, aws.Regions[utils.Cfg.FileSettings.AmazonS3Region])
|
s := s3.New(auth, awsRegion())
|
||||||
bucket := s.Bucket(utils.Cfg.FileSettings.AmazonS3Bucket)
|
bucket := s.Bucket(utils.Cfg.FileSettings.AmazonS3Bucket)
|
||||||
|
|
||||||
ext := filepath.Ext(path)
|
ext := filepath.Ext(path)
|
||||||
@@ -578,7 +578,7 @@ func readFile(path string) ([]byte, *model.AppError) {
|
|||||||
auth.AccessKey = utils.Cfg.FileSettings.AmazonS3AccessKeyId
|
auth.AccessKey = utils.Cfg.FileSettings.AmazonS3AccessKeyId
|
||||||
auth.SecretKey = utils.Cfg.FileSettings.AmazonS3SecretAccessKey
|
auth.SecretKey = utils.Cfg.FileSettings.AmazonS3SecretAccessKey
|
||||||
|
|
||||||
s := s3.New(auth, aws.Regions[utils.Cfg.FileSettings.AmazonS3Region])
|
s := s3.New(auth, awsRegion())
|
||||||
bucket := s.Bucket(utils.Cfg.FileSettings.AmazonS3Bucket)
|
bucket := s.Bucket(utils.Cfg.FileSettings.AmazonS3Bucket)
|
||||||
|
|
||||||
// try to get the file from S3 with some basic retry logic
|
// try to get the file from S3 with some basic retry logic
|
||||||
@@ -629,3 +629,17 @@ func openFileWriteStream(path string) (io.Writer, *model.AppError) {
|
|||||||
func closeFileWriteStream(file io.Writer) {
|
func closeFileWriteStream(file io.Writer) {
|
||||||
file.(*os.File).Close()
|
file.(*os.File).Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func awsRegion() aws.Region {
|
||||||
|
if region, ok := aws.Regions[utils.Cfg.FileSettings.AmazonS3Region]; ok {
|
||||||
|
return region
|
||||||
|
}
|
||||||
|
|
||||||
|
return aws.Region{
|
||||||
|
Name: utils.Cfg.FileSettings.AmazonS3Region,
|
||||||
|
S3Endpoint: utils.Cfg.FileSettings.AmazonS3Endpoint,
|
||||||
|
S3BucketEndpoint: utils.Cfg.FileSettings.AmazonS3BucketEndpoint,
|
||||||
|
S3LocationConstraint: *utils.Cfg.FileSettings.AmazonS3LocationConstraint,
|
||||||
|
S3LowercaseBucket: *utils.Cfg.FileSettings.AmazonS3LowercaseBucket,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -68,21 +68,25 @@ type LogSettings struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type FileSettings struct {
|
type FileSettings struct {
|
||||||
DriverName string
|
DriverName string
|
||||||
Directory string
|
Directory string
|
||||||
EnablePublicLink bool
|
EnablePublicLink bool
|
||||||
PublicLinkSalt string
|
PublicLinkSalt string
|
||||||
ThumbnailWidth int
|
ThumbnailWidth int
|
||||||
ThumbnailHeight int
|
ThumbnailHeight int
|
||||||
PreviewWidth int
|
PreviewWidth int
|
||||||
PreviewHeight int
|
PreviewHeight int
|
||||||
ProfileWidth int
|
ProfileWidth int
|
||||||
ProfileHeight int
|
ProfileHeight int
|
||||||
InitialFont string
|
InitialFont string
|
||||||
AmazonS3AccessKeyId string
|
AmazonS3AccessKeyId string
|
||||||
AmazonS3SecretAccessKey string
|
AmazonS3SecretAccessKey string
|
||||||
AmazonS3Bucket string
|
AmazonS3Bucket string
|
||||||
AmazonS3Region string
|
AmazonS3Region string
|
||||||
|
AmazonS3Endpoint string
|
||||||
|
AmazonS3BucketEndpoint string
|
||||||
|
AmazonS3LocationConstraint *bool
|
||||||
|
AmazonS3LowercaseBucket *bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type EmailSettings struct {
|
type EmailSettings struct {
|
||||||
@@ -210,6 +214,16 @@ func (o *Config) SetDefaults() {
|
|||||||
o.FileSettings.PublicLinkSalt = NewRandomString(32)
|
o.FileSettings.PublicLinkSalt = NewRandomString(32)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if o.FileSettings.AmazonS3LocationConstraint == nil {
|
||||||
|
o.FileSettings.AmazonS3LocationConstraint = new(bool)
|
||||||
|
*o.FileSettings.AmazonS3LocationConstraint = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if o.FileSettings.AmazonS3LowercaseBucket == nil {
|
||||||
|
o.FileSettings.AmazonS3LowercaseBucket = new(bool)
|
||||||
|
*o.FileSettings.AmazonS3LowercaseBucket = false
|
||||||
|
}
|
||||||
|
|
||||||
if len(o.EmailSettings.InviteSalt) == 0 {
|
if len(o.EmailSettings.InviteSalt) == 0 {
|
||||||
o.EmailSettings.InviteSalt = NewRandomString(32)
|
o.EmailSettings.InviteSalt = NewRandomString(32)
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user