Commit 230b533b authored by chenhan wang's avatar chenhan wang
Browse files

version

parent 9d8521e6
......@@ -29,16 +29,15 @@ type File struct {
User string `json:"user"`
Passwd string `json:"passwd"`
SessionId string `json:"sessionId"`
FileLink string `json:"fileLink"`
FileLink string `json:"fileLink"`
//Expiry time.Time `json:"expiry"` // 有效期
//Content string `json:"content"`
}
type pass struct {
SessionId string `json:"sessionId"`
Passwd string `json:"passwd"`
FileLink string `json:"fileLink"`
SessionId string `json:"sessionId"`
Passwd string `json:"passwd"`
FileLink string `json:"fileLink"`
}
type Text struct {
......@@ -63,7 +62,7 @@ func AskPasswd(c echo.Context) error {
return echo.ErrBadRequest
}
if model.Createlink(info.SessionId,info.Passwd,info.FileLink)==true{
if model.Createlink(info.SessionId, info.Passwd, info.FileLink) == true {
// 成功建立连接
SetCookie(c, info)
return c.String(http.StatusOK, "登录成功")
......@@ -142,12 +141,12 @@ func RecvFile(c echo.Context) error {
}
// 更新数据库
dinfo:=model.Users{
dinfo := model.Users{
Username: info.User,
Passwd: info.Passwd,
Name:info.FileName,// 无后缀
Size: uint(fi.Size()),
Route:filePath,
Passwd: info.Passwd,
Name: info.FileName, // 无后缀
Size: uint(fi.Size()),
Route: filePath,
//Time1: info.Expiry,
}
model.Createuser(dinfo) // 数据库一条新纪录
......@@ -166,16 +165,16 @@ func SendFile(c echo.Context) error {
info.FileType = "txt"
}
if model.find(info.FileLink,info.SessionId,)==false{
cookie,err:=c.Cookie(info.SessionId)
if err!=nil{
if model.find(info.FileLink, info.SessionId) == false {
cookie, err := c.Cookie(info.SessionId)
if err != nil {
return err
}
if cookie.Value!=info.FileLink{
if cookie.Value != info.FileLink {
return err // you wenti
}
}
filePath := "./files/" + info.FileType + "/" + info.FileName + "." + info.FileType
src, err := os.Open(filePath)
if err != nil {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment