|
@ -221,7 +221,7 @@ func (uploader *Uploader) doUploadData(data []byte, option *UploadOption) (uploa |
|
|
// this could be double copying
|
|
|
// this could be double copying
|
|
|
clearDataLen = len(data) |
|
|
clearDataLen = len(data) |
|
|
clearData := data |
|
|
clearData := data |
|
|
if shouldGzipNow && !option.Cipher { |
|
|
|
|
|
|
|
|
if shouldGzipNow { |
|
|
compressed, compressErr := util.GzipData(data) |
|
|
compressed, compressErr := util.GzipData(data) |
|
|
// fmt.Printf("data is compressed from %d ==> %d\n", len(data), len(compressed))
|
|
|
// fmt.Printf("data is compressed from %d ==> %d\n", len(data), len(compressed))
|
|
|
if compressErr == nil { |
|
|
if compressErr == nil { |
|
@ -241,7 +241,7 @@ func (uploader *Uploader) doUploadData(data []byte, option *UploadOption) (uploa |
|
|
|
|
|
|
|
|
// encrypt
|
|
|
// encrypt
|
|
|
cipherKey := util.GenCipherKey() |
|
|
cipherKey := util.GenCipherKey() |
|
|
encryptedData, encryptionErr := util.Encrypt(clearData, cipherKey) |
|
|
|
|
|
|
|
|
encryptedData, encryptionErr := util.Encrypt(data, cipherKey) |
|
|
if encryptionErr != nil { |
|
|
if encryptionErr != nil { |
|
|
err = fmt.Errorf("encrypt input: %v", encryptionErr) |
|
|
err = fmt.Errorf("encrypt input: %v", encryptionErr) |
|
|
return |
|
|
return |
|
@ -267,6 +267,9 @@ func (uploader *Uploader) doUploadData(data []byte, option *UploadOption) (uploa |
|
|
uploadResult.Mime = option.MimeType |
|
|
uploadResult.Mime = option.MimeType |
|
|
uploadResult.CipherKey = cipherKey |
|
|
uploadResult.CipherKey = cipherKey |
|
|
uploadResult.Size = uint32(clearDataLen) |
|
|
uploadResult.Size = uint32(clearDataLen) |
|
|
|
|
|
if contentIsGzipped { |
|
|
|
|
|
uploadResult.Gzip = 1 |
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
// upload data
|
|
|
// upload data
|
|
|
uploadResult, err = uploader.upload_content(func(w io.Writer) (err error) { |
|
|
uploadResult, err = uploader.upload_content(func(w io.Writer) (err error) { |
|
|