Skip to content
Snippets Groups Projects
Unverified Commit 8cee8cb3 authored by Travis Ralston's avatar Travis Ralston Committed by GitHub
Browse files

Merge pull request #342 from russelldavies/master

Add support for S3 storage classes
parents 02c73866 fe71e44f
No related branches found
No related tags found
No related merge requests found
......@@ -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
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment