Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
e4541a7f
Commit
e4541a7f
authored
Oct 04, 2017
by
Ricard Clau
Committed by
Torkel Ödegaard
Oct 04, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support for s3 path (#9151)
parent
0c31c7b1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
3 deletions
+18
-3
conf/defaults.ini
+1
-0
conf/sample.ini
+1
-0
docs/sources/installation/configuration.md
+5
-0
pkg/components/imguploader/imguploader.go
+7
-1
pkg/components/imguploader/s3uploader.go
+4
-2
No files found.
conf/defaults.ini
View file @
e4541a7f
...
...
@@ -479,6 +479,7 @@ provider =
bucket_url
=
bucket
=
region
=
path
=
access_key
=
secret_key
=
...
...
conf/sample.ini
View file @
e4541a7f
...
...
@@ -424,6 +424,7 @@
[external_image_storage.s3]
;bucket =
;region =
;path =
;access_key =
;secret_key =
...
...
docs/sources/installation/configuration.md
View file @
e4541a7f
...
...
@@ -651,11 +651,16 @@ These options control how images should be made public so they can be shared on
You can choose between (s3, webdav, gcs). 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
### path
Optional extra path inside bucket, useful to apply expiration policies
### 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.
...
...
pkg/components/imguploader/imguploader.go
View file @
e4541a7f
...
...
@@ -30,9 +30,15 @@ func NewImageUploader() (ImageUploader, error) {
bucket
:=
s3sec
.
Key
(
"bucket"
)
.
MustString
(
""
)
region
:=
s3sec
.
Key
(
"region"
)
.
MustString
(
""
)
path
:=
s3sec
.
Key
(
"path"
)
.
MustString
(
""
)
bucketUrl
:=
s3sec
.
Key
(
"bucket_url"
)
.
MustString
(
""
)
accessKey
:=
s3sec
.
Key
(
"access_key"
)
.
MustString
(
""
)
secretKey
:=
s3sec
.
Key
(
"secret_key"
)
.
MustString
(
""
)
if
path
!=
""
&&
path
[
len
(
path
)
-
1
:
]
!=
"/"
{
path
+=
"/"
}
if
bucket
==
""
||
region
==
""
{
info
,
err
:=
getRegionAndBucketFromUrl
(
bucketUrl
)
if
err
!=
nil
{
...
...
@@ -42,7 +48,7 @@ func NewImageUploader() (ImageUploader, error) {
region
=
info
.
region
}
return
NewS3Uploader
(
region
,
bucket
,
"public-read"
,
accessKey
,
secretKey
),
nil
return
NewS3Uploader
(
region
,
bucket
,
path
,
"public-read"
,
accessKey
,
secretKey
),
nil
case
"webdav"
:
webdavSec
,
err
:=
setting
.
Cfg
.
GetSection
(
"external_image_storage.webdav"
)
if
err
!=
nil
{
...
...
pkg/components/imguploader/s3uploader.go
View file @
e4541a7f
...
...
@@ -19,16 +19,18 @@ import (
type
S3Uploader
struct
{
region
string
bucket
string
path
string
acl
string
secretKey
string
accessKey
string
log
log
.
Logger
}
func
NewS3Uploader
(
region
,
bucket
,
acl
,
accessKey
,
secretKey
string
)
*
S3Uploader
{
func
NewS3Uploader
(
region
,
bucket
,
path
,
acl
,
accessKey
,
secretKey
string
)
*
S3Uploader
{
return
&
S3Uploader
{
region
:
region
,
bucket
:
bucket
,
path
:
path
,
acl
:
acl
,
accessKey
:
accessKey
,
secretKey
:
secretKey
,
...
...
@@ -56,7 +58,7 @@ func (u *S3Uploader) Upload(ctx context.Context, imageDiskPath string) (string,
}
s3_endpoint
,
_
:=
endpoints
.
DefaultResolver
()
.
EndpointFor
(
"s3"
,
u
.
region
)
key
:=
util
.
GetRandomString
(
20
)
+
".png"
key
:=
u
.
path
+
u
til
.
GetRandomString
(
20
)
+
".png"
image_url
:=
s3_endpoint
.
URL
+
"/"
+
u
.
bucket
+
"/"
+
key
log
.
Debug
(
"Uploading image to s3"
,
"url = "
,
image_url
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment