aboutsummaryrefslogtreecommitdiff
path: root/weed/storage
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-06-23 09:12:02 -0700
committerChris Lu <chris.lu@gmail.com>2020-06-23 09:12:02 -0700
commitfe60db404acc581dcadf400a9fb8a41cecb4bb09 (patch)
treee20e9e8782512a552759580ba3dfdd2df857bac3 /weed/storage
parenta4e3cffe0a452ad12b5aa9e3f57113a0fa4ba7ce (diff)
downloadseaweedfs-fe60db404acc581dcadf400a9fb8a41cecb4bb09.tar.xz
seaweedfs-fe60db404acc581dcadf400a9fb8a41cecb4bb09.zip
prepare for zstd
Diffstat (limited to 'weed/storage')
-rw-r--r--weed/storage/needle/needle_parse_upload.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/weed/storage/needle/needle_parse_upload.go b/weed/storage/needle/needle_parse_upload.go
index 67b798821..dcbfd3819 100644
--- a/weed/storage/needle/needle_parse_upload.go
+++ b/weed/storage/needle/needle_parse_upload.go
@@ -21,6 +21,7 @@ type ParsedUpload struct {
MimeType string
PairMap map[string]string
IsGzipped bool
+ IsZstd bool
OriginalDataSize int
ModifiedTime uint64
Ttl *TTL
@@ -67,7 +68,7 @@ func ParseUpload(r *http.Request, sizeLimit int64) (pu *ParsedUpload, e error) {
}
} else {
ext := filepath.Base(pu.FileName)
- if shouldGzip, iAmSure := util.IsGzippableFileType(ext, pu.MimeType); pu.MimeType == "" && !iAmSure || shouldGzip && iAmSure {
+ if shouldBeCompressed, iAmSure := util.IsCompressableFileType(ext, pu.MimeType); pu.MimeType == "" && !iAmSure || shouldBeCompressed && iAmSure {
// println("ext", ext, "iAmSure", iAmSure, "shouldGzip", shouldGzip, "mimeType", pu.MimeType)
if compressedData, err := util.GzipData(pu.Data); err == nil {
if len(compressedData)*10 < len(pu.Data)*9 {
@@ -83,6 +84,7 @@ func ParseUpload(r *http.Request, sizeLimit int64) (pu *ParsedUpload, e error) {
func parsePut(r *http.Request, sizeLimit int64, pu *ParsedUpload) (e error) {
pu.IsGzipped = r.Header.Get("Content-Encoding") == "gzip"
+ pu.IsZstd = r.Header.Get("Content-Encoding") == "zstd"
pu.MimeType = r.Header.Get("Content-Type")
pu.FileName = ""
pu.Data, e = ioutil.ReadAll(io.LimitReader(r.Body, sizeLimit+1))
@@ -176,6 +178,7 @@ func parseMultipart(r *http.Request, sizeLimit int64, pu *ParsedUpload) (e error
}
pu.IsGzipped = part.Header.Get("Content-Encoding") == "gzip"
+ pu.IsZstd = part.Header.Get("Content-Encoding") == "zstd"
}
return