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

Commit 4667f2c

Browse files
authored
storage: Add SSE part in formatFileObject (#17)
* add SSE part in formatFileObject * refactor * fix NPE and do not check "" * add ServerEncrypted * fix
1 parent b570de7 commit 4667f2c

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

generated.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

service.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,7 @@ type = "string"
4848
type = "string"
4949

5050
[infos.object.meta.encryption-scope]
51-
type = "string"
51+
type = "string"
52+
53+
[infos.object.meta.server-encrypted]
54+
type = "bool"

storage.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/base64"
66
"fmt"
77
"io"
8+
"strconv"
89

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

@@ -209,6 +210,9 @@ func (s *Storage) stat(ctx context.Context, path string, opt pairStorageStat) (o
209210
if v := output.EncryptionScope(); v != "" {
210211
sm.EncryptionScope = v
211212
}
213+
if v, err := strconv.ParseBool(output.IsServerEncrypted()); err == nil {
214+
sm.ServerEncrypted = v
215+
}
212216
o.SetServiceMetadata(sm)
213217

214218
return o, nil

utils.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ func (s *Storage) formatFileObject(v azblob.BlobItemInternal) (o *typ.Object, er
283283
if v.Properties.ContentLength != nil {
284284
o.SetContentLength(*v.Properties.ContentLength)
285285
}
286-
if v.Properties.ContentType != nil && *v.Properties.ContentType != "" {
286+
if v.Properties.ContentType != nil {
287287
o.SetContentType(*v.Properties.ContentType)
288288
}
289289
if len(v.Properties.ContentMD5) > 0 {
@@ -294,6 +294,15 @@ func (s *Storage) formatFileObject(v azblob.BlobItemInternal) (o *typ.Object, er
294294
if value := v.Properties.AccessTier; value != "" {
295295
sm.AccessTier = string(value)
296296
}
297+
if v.Properties.CustomerProvidedKeySha256 != nil {
298+
sm.EncryptionKeySha256 = *v.Properties.CustomerProvidedKeySha256
299+
}
300+
if v.Properties.EncryptionScope != nil {
301+
sm.EncryptionScope = *v.Properties.EncryptionScope
302+
}
303+
if v.Properties.ServerEncrypted != nil {
304+
sm.ServerEncrypted = *v.Properties.ServerEncrypted
305+
}
297306
o.SetServiceMetadata(sm)
298307

299308
return o, nil

0 commit comments

Comments
 (0)