Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
matrix-media-repo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
matrix-media-repo
Commits
fe71e44f
Commit
fe71e44f
authored
3 years ago
by
Russell Davies
Browse files
Options
Downloads
Patches
Plain Diff
Add support for S3 storage classes
parent
02c73866
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
storage/datastore/ds_s3/s3_store.go
+8
-2
8 additions, 2 deletions
storage/datastore/ds_s3/s3_store.go
with
8 additions
and
2 deletions
storage/datastore/ds_s3/s3_store.go
+
8
−
2
View file @
fe71e44f
...
...
@@ -27,6 +27,7 @@ type s3Datastore struct {
bucket
string
region
string
tempPath
string
storageClass
string
}
func
GetOrCreateS3Datastore
(
dsId
string
,
conf
config
.
DatastoreConfig
)
(
*
s3Datastore
,
error
)
{
...
...
@@ -40,12 +41,16 @@ func GetOrCreateS3Datastore(dsId string, conf config.DatastoreConfig) (*s3Datast
accessSecret
,
secretFound
:=
conf
.
Options
[
"accessSecret"
]
region
,
regionFound
:=
conf
.
Options
[
"region"
]
tempPath
,
tempPathFound
:=
conf
.
Options
[
"tempPath"
]
storageClass
,
storageClassFound
:=
conf
.
Options
[
"storageClass"
]
if
!
epFound
||
!
bucketFound
||
!
keyFound
||
!
secretFound
{
return
nil
,
errors
.
New
(
"invalid configuration: missing s3 options"
)
}
if
!
tempPathFound
{
logrus
.
Warn
(
"Datastore "
,
dsId
,
" (s3) does not have a tempPath set - this could lead to excessive memory usage by the media repo"
)
}
if
!
storageClassFound
{
storageClass
=
"STANDARD"
}
useSsl
:=
true
useSslStr
,
sslFound
:=
conf
.
Options
[
"ssl"
]
...
...
@@ -72,6 +77,7 @@ func GetOrCreateS3Datastore(dsId string, conf config.DatastoreConfig) (*s3Datast
bucket
:
bucket
,
region
:
region
,
tempPath
:
tempPath
,
storageClass
:
storageClass
,
}
stores
[
dsId
]
=
s3ds
return
s3ds
,
nil
...
...
@@ -177,7 +183,7 @@ func (s *s3Datastore) UploadFile(file io.ReadCloser, expectedLength int64, ctx r
}
}
ctx
.
Log
.
Info
(
"Uploading file..."
)
sizeBytes
,
uploadErr
=
s
.
client
.
PutObjectWithContext
(
ctx
,
s
.
bucket
,
objectName
,
rs3
,
expectedLength
,
minio
.
PutObjectOptions
{})
sizeBytes
,
uploadErr
=
s
.
client
.
PutObjectWithContext
(
ctx
,
s
.
bucket
,
objectName
,
rs3
,
expectedLength
,
minio
.
PutObjectOptions
{
StorageClass
:
s
.
storageClass
})
ctx
.
Log
.
Info
(
"Uploaded "
,
sizeBytes
,
" bytes to s3"
)
done
<-
true
}()
...
...
@@ -224,6 +230,6 @@ func (s *s3Datastore) ObjectExists(location string) bool {
func
(
s
*
s3Datastore
)
OverwriteObject
(
location
string
,
stream
io
.
ReadCloser
)
error
{
defer
cleanup
.
DumpAndCloseStream
(
stream
)
_
,
err
:=
s
.
client
.
PutObject
(
s
.
bucket
,
location
,
stream
,
-
1
,
minio
.
PutObjectOptions
{})
_
,
err
:=
s
.
client
.
PutObject
(
s
.
bucket
,
location
,
stream
,
-
1
,
minio
.
PutObjectOptions
{
StorageClass
:
s
.
storageClass
})
return
err
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment