Skip to content
This repository was archived by the owner on Oct 22, 2021. It is now read-only.

Implement appender support #15

Merged
merged 5 commits into from
Apr 25, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
modify newObject stat parameter and add SSE support for append
  • Loading branch information
JinnyYi committed Apr 25, 2021
commit 3671f21ecc6dcc7b7e7535a3c445a761a11c7bbe
47 changes: 41 additions & 6 deletions generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.14
require (
github.com/aliyun/aliyun-oss-go-sdk v2.1.8+incompatible
github.com/aos-dev/go-integration-test/v3 v3.0.0
github.com/aos-dev/go-storage/v3 v3.5.1-0.20210422060150-bc0fae4c3fa7
github.com/aos-dev/go-storage/v3 v3.6.0
github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect
github.com/google/uuid v1.2.0
github.com/satori/go.uuid v1.2.0 // indirect
Expand Down
11 changes: 6 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
github.com/Xuanwo/templateutils v0.0.0-20201216100309-46f73cd4e4b1 h1:SQ8kQujQ0yl39YBMU0xZ+yyfxx/qSWfGWlCPNzHp5kw=
github.com/Xuanwo/templateutils v0.0.0-20201216100309-46f73cd4e4b1/go.mod h1:x0qS7gfgEm24b8V9U+0zBEBAu/VpxZhO/+EWtpgEgDw=
github.com/Xuanwo/templateutils v0.1.0 h1:WpkWOqQtIQ2vAIpJLa727DdN8WtxhUkkbDGa6UhntJY=
github.com/Xuanwo/templateutils v0.1.0/go.mod h1:OdE0DJ+CJxDBq6psX5DPV+gOZi8bhuHuVUpPCG++Wb8=
github.com/aliyun/aliyun-oss-go-sdk v2.1.8+incompatible h1:hLUNPbx10wawWW7DeNExvTrlb90db3UnnNTFKHZEFhE=
github.com/aliyun/aliyun-oss-go-sdk v2.1.8+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
github.com/aos-dev/go-integration-test/v3 v3.0.0 h1:rxIc7YBfiw9JS5JiVU4BZAqQqoKJemIftFaeJpYCb5M=
github.com/aos-dev/go-integration-test/v3 v3.0.0/go.mod h1:woC3E9Ld1G/Cpo2tSEQ+iwIr4MMdgf+L/8UuyJOE11Q=
github.com/aos-dev/go-storage/v3 v3.5.0/go.mod h1:PZJT0Ta7YxVM5QoYoh8Q/X4I6e/z/7gOJqm85Aib4nY=
github.com/aos-dev/go-storage/v3 v3.5.1-0.20210422060150-bc0fae4c3fa7 h1:YirUP3+06blEpQ/o6VT0RXRf5ystxNB91iaYgO0SoWM=
github.com/aos-dev/go-storage/v3 v3.5.1-0.20210422060150-bc0fae4c3fa7/go.mod h1:JFshvl851ZDDXtFGWDFKqkg34QEPH0xuhLJ2LjikZYc=
github.com/aos-dev/go-storage/v3 v3.6.0 h1:ywjMvh320+esJH81MqB9nyuMNLW97Krujz2UiprC2ZM=
github.com/aos-dev/go-storage/v3 v3.6.0/go.mod h1:ZQwybmoCcTWUOWg+G15gT/NQJoI8G8KH1pF41TuJqYk=
github.com/aos-dev/specs/go v0.0.0-20210312090615-23109627848b/go.mod h1:XTNlLZtPA1inITyDH5hNnQXVjvvKUvo+lurs5GYB8NA=
github.com/aos-dev/specs/go v0.0.0-20210420062803-1a60efa2eae3 h1:LiW0Ki0Gw6opu11JwMhxWw5M+V6I9JypJ5eAIp+Rqt4=
github.com/aos-dev/specs/go v0.0.0-20210420062803-1a60efa2eae3/go.mod h1:gNah3KaPJEfysh7uCCX+sYjQC3g2yx2VgBkFlT945Ws=
github.com/aos-dev/specs/go v0.0.0-20210423110314-8361397c2bf3 h1:e65ozDhdfHfhnDpZF9SLcY5mwtAg/sAvNIUAkFd+4D0=
github.com/aos-dev/specs/go v0.0.0-20210423110314-8361397c2bf3/go.mod h1:gNah3KaPJEfysh7uCCX+sYjQC3g2yx2VgBkFlT945Ws=
github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f h1:ZNv7On9kyUzm7fvRZumSyy/IUiSC7AzL0I1jKKtwooA=
github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f/go.mod h1:AuiFmCCPBSrqvVMvuqFuk0qogytodnVFVSN5CeJB8Gc=
github.com/dave/dst v0.26.2 h1:lnxLAKI3tx7MgLNVDirFCsDTlTG9nKTk7GcptKcWSwY=
Expand Down
3 changes: 3 additions & 0 deletions service.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ optional = ["offset", "io_callback", "size"]
[namespace.storage.op.write]
optional = ["content_md5", "content_type", "io_callback", "storage_class", "server_side_encryption", "server_side_data_encryption", "server_side_encryption_key_id"]

[namespace.storage.op.write_append]
optional = ["server_side_encryption", "server_side_data_encryption", "server_side_encryption_key_id"]

[pairs.default_service_pairs]
type = "DefaultServicePairs"
description = "set default pairs for service actions"
Expand Down
19 changes: 14 additions & 5 deletions storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (s *Storage) create(path string, opt pairStorageCreate) (o *Object) {
}

func (s *Storage) createAppend(ctx context.Context, path string, opt pairStorageCreateAppend) (o *Object, err error) {
o = s.newObject(false)
o = s.newObject(true)
o.Mode = ModeRead | ModeAppend
o.ID = s.getAbsPath(path)
o.Path = path
Expand Down Expand Up @@ -194,15 +194,15 @@ func (s *Storage) stat(ctx context.Context, path string, opt pairStorageStat) (o
o.SetContentType(v)
}

sm := make(map[string]string)
var sm ObjectMetadata
if v := output.Get(storageClassHeader); v != "" {
sm[MetadataStorageClass] = v
sm.StorageClass = v
}
if v := output.Get(serverSideEncryptionHeader); v != "" {
sm[MetadataServerSideEncryption] = v
sm.ServerSideEncryption = v
}
if v := output.Get(serverSideEncryptionKeyIdHeader); v != "" {
sm[MetadataServerSideEncryptionKeyID] = v
sm.ServerSideEncryptionKeyID = v
}
o.SetServiceMetadata(sm)

Expand Down Expand Up @@ -252,6 +252,15 @@ func (s *Storage) writeAppend(ctx context.Context, o *Object, r io.Reader, size

options := make([]oss.Option, 0)
options = append(options, oss.ContentLength(size))
if opt.HasServerSideEncryption {
options = append(options, oss.ServerSideEncryption(opt.ServerSideEncryption))
}
if opt.HasServerSideDataEncryption {
options = append(options, oss.ServerSideDataEncryption(opt.ServerSideDataEncryption))
}
if opt.HasServerSideEncryptionKeyID {
options = append(options, oss.ServerSideEncryptionKeyID(opt.ServerSideEncryptionKeyID))
}

offset, err = s.bucket.AppendObject(rp, r, offset, options...)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,9 @@ func (s *Storage) formatFileObject(v oss.ObjectProperties) (o *typ.Object, err e
o.SetEtag(v.ETag)
}

sm := make(map[string]string)
var sm ObjectMetadata
if value := v.Type; value != "" {
sm[MetadataStorageClass] = value
sm.StorageClass = value
}
o.SetServiceMetadata(sm)

Expand Down