mirror of
https://github.com/grafana/grafana.git
synced 2024-11-22 08:56:43 -06:00
config bucket and region for s3 uploader
this is to support cn-north-1 region as it can get s3 url programatically. also keeps support 'bucket_url' for backward compatiblity
This commit is contained in:
parent
37962216ed
commit
88a8991722
@ -458,7 +458,8 @@ url = https://grafana.com
|
||||
provider =
|
||||
|
||||
[external_image_storage.s3]
|
||||
bucket_url =
|
||||
bucket =
|
||||
region =
|
||||
access_key =
|
||||
secret_key =
|
||||
|
||||
|
@ -403,7 +403,8 @@
|
||||
;provider =
|
||||
|
||||
[external_image_storage.s3]
|
||||
;bucket_url =
|
||||
;bucket =
|
||||
;region =
|
||||
;access_key =
|
||||
;secret_key =
|
||||
|
||||
|
@ -648,12 +648,16 @@ These options control how images should be made public so they can be shared on
|
||||
You can choose between (s3, webdav). If left empty Grafana will ignore the upload action.
|
||||
|
||||
## [external_image_storage.s3]
|
||||
### bucket
|
||||
Bucket name for S3. e.g. grafana.snapshot
|
||||
### region
|
||||
Region name for S3. e.g. 'us-east-1', 'cn-north-1', etc
|
||||
|
||||
### bucket_url
|
||||
(for backward compatibility, only works when no bucket or region are configured)
|
||||
Bucket URL for S3. AWS region can be specified within URL or defaults to 'us-east-1', e.g.
|
||||
- http://grafana.s3.amazonaws.com/
|
||||
- https://grafana.s3-ap-southeast-2.amazonaws.com/
|
||||
- https://grafana.s3-cn-north-1.amazonaws.com.cn
|
||||
|
||||
### access_key
|
||||
Access key. e.g. AAAAAAAAAAAAAAAAAAAA
|
||||
|
@ -27,15 +27,21 @@ func NewImageUploader() (ImageUploader, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bucket := s3sec.Key("bucket").MustString("")
|
||||
region := s3sec.Key("region").MustString("")
|
||||
bucketUrl := s3sec.Key("bucket_url").MustString("")
|
||||
accessKey := s3sec.Key("access_key").MustString("")
|
||||
secretKey := s3sec.Key("secret_key").MustString("")
|
||||
info, err := getRegionAndBucketFromUrl(bucketUrl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if bucket == "" || region == "" {
|
||||
info, err := getRegionAndBucketFromUrl(bucketUrl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
bucket = info.bucket
|
||||
region = info.region
|
||||
}
|
||||
|
||||
return NewS3Uploader(info.region, info.bucket, "public-read", accessKey, secretKey), nil
|
||||
return NewS3Uploader(region, bucket, "public-read", accessKey, secretKey), nil
|
||||
case "webdav":
|
||||
webdavSec, err := setting.Cfg.GetSection("external_image_storage.webdav")
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user