add md5 hash for file info
This commit is contained in:
parent
f17d9d9801
commit
a8823dcb19
BIN
APIServer.exe
BIN
APIServer.exe
Binary file not shown.
10
APIServer.go
10
APIServer.go
@ -3,6 +3,8 @@ package main
|
||||
import (
|
||||
"APIServer/cnf"
|
||||
"APIServer/ews"
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"flag"
|
||||
@ -311,7 +313,7 @@ func handleFileInfo(w http.ResponseWriter, r *http.Request) {
|
||||
FileName string `json:"FileName"`
|
||||
FileSize int64 `json:"FileSize"`
|
||||
LastModified string `json:"LastModified"`
|
||||
//MD5Hash string `json:"MD5Hash"`
|
||||
MD5Hash string `json:"MD5Hash"`
|
||||
}
|
||||
type FileList struct {
|
||||
FileList []FileInfo `json:"FileList"`
|
||||
@ -324,7 +326,7 @@ func handleFileInfo(w http.ResponseWriter, r *http.Request) {
|
||||
fileInfo.FileName = info.Name()
|
||||
fileInfo.FileSize = info.Size()
|
||||
fileInfo.LastModified = info.ModTime().Format("2006-01-02 15:04:05")
|
||||
//fileInfo.MD5Hash = fileMD5(path)
|
||||
fileInfo.MD5Hash = fileMD5(path)
|
||||
infoList = append(infoList, fileInfo)
|
||||
}
|
||||
return nil
|
||||
@ -471,7 +473,7 @@ func parseReqParams(r *http.Request) (map[string]string, error) {
|
||||
return params, nil
|
||||
}
|
||||
|
||||
/* func fileMD5(filePath string) string {
|
||||
func fileMD5(filePath string) string {
|
||||
file, err := os.Open(filePath)
|
||||
if err != nil {
|
||||
return ""
|
||||
@ -482,7 +484,7 @@ func parseReqParams(r *http.Request) (map[string]string, error) {
|
||||
return ""
|
||||
}
|
||||
return hex.EncodeToString(hash.Sum(nil))
|
||||
} */
|
||||
}
|
||||
|
||||
func chkParams(arg string) bool {
|
||||
if strings.Contains(arg, ";") ||
|
||||
|
Loading…
x
Reference in New Issue
Block a user