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

storage: Add SSE part in formatFileObject #17

Merged
merged 5 commits into from
Apr 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions generated.go

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

5 changes: 4 additions & 1 deletion service.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,7 @@ type = "string"
type = "string"

[infos.object.meta.encryption-scope]
type = "string"
type = "string"

[infos.object.meta.server-encrypted]
type = "bool"
4 changes: 4 additions & 0 deletions storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/base64"
"fmt"
"io"
"strconv"

"github.com/Azure/azure-storage-blob-go/azblob"

Expand Down Expand Up @@ -209,6 +210,9 @@ func (s *Storage) stat(ctx context.Context, path string, opt pairStorageStat) (o
if v := output.EncryptionScope(); v != "" {
sm.EncryptionScope = v
}
if v, err := strconv.ParseBool(output.IsServerEncrypted()); err == nil {
sm.ServerEncrypted = v
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be err == nil……

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An IsServerEncrypted API returns string, so weird.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's because ...

// IsServerEncrypted returns the value for header x-ms-server-encrypted.
func (bgpr BlobGetPropertiesResponse) IsServerEncrypted() string {
	return bgpr.rawResponse.Header.Get("x-ms-server-encrypted")
}

o.SetServiceMetadata(sm)

return o, nil
Expand Down
11 changes: 10 additions & 1 deletion utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func (s *Storage) formatFileObject(v azblob.BlobItemInternal) (o *typ.Object, er
if v.Properties.ContentLength != nil {
o.SetContentLength(*v.Properties.ContentLength)
}
if v.Properties.ContentType != nil && *v.Properties.ContentType != "" {
if v.Properties.ContentType != nil {
o.SetContentType(*v.Properties.ContentType)
}
if len(v.Properties.ContentMD5) > 0 {
Expand All @@ -294,6 +294,15 @@ func (s *Storage) formatFileObject(v azblob.BlobItemInternal) (o *typ.Object, er
if value := v.Properties.AccessTier; value != "" {
sm.AccessTier = string(value)
}
if v.Properties.CustomerProvidedKeySha256 != nil {
sm.EncryptionKeySha256 = *v.Properties.CustomerProvidedKeySha256
}
if v.Properties.EncryptionScope != nil {
sm.EncryptionScope = *v.Properties.EncryptionScope
}
if v.Properties.ServerEncrypted != nil {
sm.ServerEncrypted = *v.Properties.ServerEncrypted
}
o.SetServiceMetadata(sm)

return o, nil
Expand Down