escaping upload file name special characters

if already gzipped, avoid gzipping again
This commit is contained in:
Chris Lu
2013-07-15 17:26:00 -07:00
parent dd66193bfb
commit 5e3b6e968a
3 changed files with 16 additions and 9 deletions

View File

@@ -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
}