mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-08-01 08:00:39 +08:00
adjust uncompress data
This commit is contained in:
parent
ca3516ac6d
commit
a735fd767c
@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"compress/flate"
|
"compress/flate"
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -29,18 +30,7 @@ func UnCompressData(input []byte) ([]byte, error) {
|
|||||||
if IsGzippedContent(input) {
|
if IsGzippedContent(input) {
|
||||||
return ungzipData(input)
|
return ungzipData(input)
|
||||||
}
|
}
|
||||||
|
return nil, fmt.Errorf("unsupported compression")
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
func ungzipData(input []byte) ([]byte, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user