diff options
| author | Chris Lu <chris.lu@gmail.com> | 2019-12-25 21:37:21 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2019-12-25 21:37:24 -0800 |
| commit | 48d28d3eb2ceabe558ec0c0abf4f66c76175a96e (patch) | |
| tree | b9f89362ace15b5767cd93dc11c053204042411b /weed/storage/backend/s3_backend/s3_upload.go | |
| parent | 997f5ead9383da02e84ac12cfa013e4a17b9a7ae (diff) | |
| download | seaweedfs-48d28d3eb2ceabe558ec0c0abf4f66c76175a96e.tar.xz seaweedfs-48d28d3eb2ceabe558ec0c0abf4f66c76175a96e.zip | |
tier: support remote file attributes and remember the file extension
Diffstat (limited to 'weed/storage/backend/s3_backend/s3_upload.go')
| -rw-r--r-- | weed/storage/backend/s3_backend/s3_upload.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/weed/storage/backend/s3_backend/s3_upload.go b/weed/storage/backend/s3_backend/s3_upload.go index 97449ea40..500a85590 100644 --- a/weed/storage/backend/s3_backend/s3_upload.go +++ b/weed/storage/backend/s3_backend/s3_upload.go @@ -8,10 +8,12 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/s3/s3iface" "github.com/aws/aws-sdk-go/service/s3/s3manager" + "github.com/chrislusf/seaweedfs/weed/glog" ) func uploadToS3(sess s3iface.S3API, filename string, destBucket string, destKey string, + attributes map[string]string, fn func(progressed int64, percentage float32) error) (fileSize int64, err error) { //open the file @@ -46,6 +48,15 @@ func uploadToS3(sess s3iface.S3API, filename string, destBucket string, destKey fn: fn, } + // process tagging + tags := "" + for k, v := range attributes { + if len(tags) > 0 { + tags = tags + "&" + } + tags = tags + k + "=" + v + } + // Upload the file to S3. var result *s3manager.UploadOutput result, err = uploader.Upload(&s3manager.UploadInput{ @@ -55,6 +66,7 @@ func uploadToS3(sess s3iface.S3API, filename string, destBucket string, destKey ACL: aws.String("private"), ServerSideEncryption: aws.String("AES256"), StorageClass: aws.String("STANDARD_IA"), + Tagging: aws.String(tags), }) //in case it fails to upload |
