mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-19 17:17:57 +08:00
renaming
This commit is contained in:
@@ -25,7 +25,25 @@ func GzipData(input []byte) ([]byte, error) {
|
||||
}
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
func UnGzipData(input []byte) ([]byte, error) {
|
||||
func UnCompressData(input []byte) ([]byte, error) {
|
||||
if IsGzippedContent(input) {
|
||||
return ungzipData(input)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func ungzipData(input []byte) ([]byte, error) {
|
||||
buf := bytes.NewBuffer(input)
|
||||
r, _ := gzip.NewReader(buf)
|
||||
defer r.Close()
|
||||
output, err := ioutil.ReadAll(r)
|
||||
if err != nil {
|
||||
glog.V(2).Infoln("error uncompressing data:", err)
|
||||
}
|
||||
return output, err
|
||||
}
|
||||
|
||||
func ungzipData(input []byte) ([]byte, error) {
|
||||
buf := bytes.NewBuffer(input)
|
||||
r, _ := gzip.NewReader(buf)
|
||||
defer r.Close()
|
||||
@@ -51,6 +69,13 @@ func IsGzippable(ext, mtype string, data []byte) bool {
|
||||
return isMostlyText
|
||||
}
|
||||
|
||||
func IsGzippedContent(data []byte) bool {
|
||||
if len(data) < 2 {
|
||||
return false
|
||||
}
|
||||
return data[0] == 31 && data[1] == 139
|
||||
}
|
||||
|
||||
/*
|
||||
* Default more not to gzip since gzip can be done on client side.
|
||||
*/func IsGzippableFileType(ext, mtype string) (shouldBeZipped, iAmSure bool) {
|
||||
|
Reference in New Issue
Block a user