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 (
|
import (
|
||||||
"APIServer/cnf"
|
"APIServer/cnf"
|
||||||
"APIServer/ews"
|
"APIServer/ews"
|
||||||
|
"crypto/md5"
|
||||||
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
@ -311,7 +313,7 @@ func handleFileInfo(w http.ResponseWriter, r *http.Request) {
|
|||||||
FileName string `json:"FileName"`
|
FileName string `json:"FileName"`
|
||||||
FileSize int64 `json:"FileSize"`
|
FileSize int64 `json:"FileSize"`
|
||||||
LastModified string `json:"LastModified"`
|
LastModified string `json:"LastModified"`
|
||||||
//MD5Hash string `json:"MD5Hash"`
|
MD5Hash string `json:"MD5Hash"`
|
||||||
}
|
}
|
||||||
type FileList struct {
|
type FileList struct {
|
||||||
FileList []FileInfo `json:"FileList"`
|
FileList []FileInfo `json:"FileList"`
|
||||||
@ -324,7 +326,7 @@ func handleFileInfo(w http.ResponseWriter, r *http.Request) {
|
|||||||
fileInfo.FileName = info.Name()
|
fileInfo.FileName = info.Name()
|
||||||
fileInfo.FileSize = info.Size()
|
fileInfo.FileSize = info.Size()
|
||||||
fileInfo.LastModified = info.ModTime().Format("2006-01-02 15:04:05")
|
fileInfo.LastModified = info.ModTime().Format("2006-01-02 15:04:05")
|
||||||
//fileInfo.MD5Hash = fileMD5(path)
|
fileInfo.MD5Hash = fileMD5(path)
|
||||||
infoList = append(infoList, fileInfo)
|
infoList = append(infoList, fileInfo)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -471,7 +473,7 @@ func parseReqParams(r *http.Request) (map[string]string, error) {
|
|||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
/* func fileMD5(filePath string) string {
|
func fileMD5(filePath string) string {
|
||||||
file, err := os.Open(filePath)
|
file, err := os.Open(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
@ -482,7 +484,7 @@ func parseReqParams(r *http.Request) (map[string]string, error) {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
return hex.EncodeToString(hash.Sum(nil))
|
return hex.EncodeToString(hash.Sum(nil))
|
||||||
} */
|
}
|
||||||
|
|
||||||
func chkParams(arg string) bool {
|
func chkParams(arg string) bool {
|
||||||
if strings.Contains(arg, ";") ||
|
if strings.Contains(arg, ";") ||
|
||||||
|
Loading…
x
Reference in New Issue
Block a user