aboutsummaryrefslogtreecommitdiff
path: root/go/weed/upload.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2013-07-15 17:26:00 -0700
committerChris Lu <chris.lu@gmail.com>2013-07-15 17:26:00 -0700
commit5e3b6e968a930a735fcb208bfeda372fe9ba7efc (patch)
tree643b3e6eb5175da86c8009d5c254cb06c1fab03b /go/weed/upload.go
parentdd66193bfbc36bb43bace01e2f88fe52f983c838 (diff)
downloadseaweedfs-5e3b6e968a930a735fcb208bfeda372fe9ba7efc.tar.xz
seaweedfs-5e3b6e968a930a735fcb208bfeda372fe9ba7efc.zip
escaping upload file name special characters
if already gzipped, avoid gzipping again
Diffstat (limited to 'go/weed/upload.go')
-rw-r--r--go/weed/upload.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/go/weed/upload.go b/go/weed/upload.go
index 8e75b387b..7256093cf 100644
--- a/go/weed/upload.go
+++ b/go/weed/upload.go
@@ -78,7 +78,12 @@ func upload(filename string, server string, fid string) (int, error) {
debug("Failed to stat file:", filename)
return 0, fiErr
}
- ret, e := operation.Upload("http://"+server+"/"+fid+"?ts="+strconv.Itoa(int(fi.ModTime().Unix())), path.Base(filename), fh, false)
+ filename = path.Base(filename)
+ isGzipped := path.Ext(filename) == ".gz"
+ if isGzipped {
+ filename = filename[0:len(filename)-3]
+ }
+ ret, e := operation.Upload("http://"+server+"/"+fid+"?ts="+strconv.Itoa(int(fi.ModTime().Unix())), filename, fh, isGzipped)
if e != nil {
return 0, e
}