diff options
| author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2024-09-15 11:47:53 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-15 08:47:53 -0700 |
| commit | 0da9e40abb9628831f47656b4b62a9d72003e9bf (patch) | |
| tree | 0ef0a49c4b8d94704a84601b92253b83d8866a05 | |
| parent | 54282293475a3a25800d96ed0c90cfb1de4ad778 (diff) | |
| download | seaweedfs-0da9e40abb9628831f47656b4b62a9d72003e9bf.tar.xz seaweedfs-0da9e40abb9628831f47656b4b62a9d72003e9bf.zip | |
Feature: compress before encryption (#6013)
| -rw-r--r-- | weed/operation/upload_content.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/weed/operation/upload_content.go b/weed/operation/upload_content.go index 8b223e769..a8e8a85b0 100644 --- a/weed/operation/upload_content.go +++ b/weed/operation/upload_content.go @@ -221,7 +221,7 @@ func (uploader *Uploader) doUploadData(data []byte, option *UploadOption) (uploa // this could be double copying clearDataLen = len(data) clearData := data - if shouldGzipNow && !option.Cipher { + if shouldGzipNow { compressed, compressErr := util.GzipData(data) // fmt.Printf("data is compressed from %d ==> %d\n", len(data), len(compressed)) if compressErr == nil { @@ -241,7 +241,7 @@ func (uploader *Uploader) doUploadData(data []byte, option *UploadOption) (uploa // encrypt cipherKey := util.GenCipherKey() - encryptedData, encryptionErr := util.Encrypt(clearData, cipherKey) + encryptedData, encryptionErr := util.Encrypt(data, cipherKey) if encryptionErr != nil { err = fmt.Errorf("encrypt input: %v", encryptionErr) return @@ -267,6 +267,9 @@ func (uploader *Uploader) doUploadData(data []byte, option *UploadOption) (uploa uploadResult.Mime = option.MimeType uploadResult.CipherKey = cipherKey uploadResult.Size = uint32(clearDataLen) + if contentIsGzipped { + uploadResult.Gzip = 1 + } } else { // upload data uploadResult, err = uploader.upload_content(func(w io.Writer) (err error) { |
