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

version

parent 9d8521e6
...@@ -29,16 +29,15 @@ type File struct { ...@@ -29,16 +29,15 @@ type File struct {
User string `json:"user"` User string `json:"user"`
Passwd string `json:"passwd"` Passwd string `json:"passwd"`
SessionId string `json:"sessionId"` SessionId string `json:"sessionId"`
FileLink string `json:"fileLink"` FileLink string `json:"fileLink"`
//Expiry time.Time `json:"expiry"` // 有效期 //Expiry time.Time `json:"expiry"` // 有效期
//Content string `json:"content"` //Content string `json:"content"`
} }
type pass struct { type pass struct {
SessionId string `json:"sessionId"` SessionId string `json:"sessionId"`
Passwd string `json:"passwd"` Passwd string `json:"passwd"`
FileLink string `json:"fileLink"` FileLink string `json:"fileLink"`
} }
type Text struct { type Text struct {
...@@ -63,7 +62,7 @@ func AskPasswd(c echo.Context) error { ...@@ -63,7 +62,7 @@ func AskPasswd(c echo.Context) error {
return echo.ErrBadRequest 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) SetCookie(c, info)
return c.String(http.StatusOK, "登录成功") return c.String(http.StatusOK, "登录成功")
...@@ -142,12 +141,12 @@ func RecvFile(c echo.Context) error { ...@@ -142,12 +141,12 @@ func RecvFile(c echo.Context) error {
} }
// 更新数据库 // 更新数据库
dinfo:=model.Users{ dinfo := model.Users{
Username: info.User, Username: info.User,
Passwd: info.Passwd, Passwd: info.Passwd,
Name:info.FileName,// 无后缀 Name: info.FileName, // 无后缀
Size: uint(fi.Size()), Size: uint(fi.Size()),
Route:filePath, Route: filePath,
//Time1: info.Expiry, //Time1: info.Expiry,
} }
model.Createuser(dinfo) // 数据库一条新纪录 model.Createuser(dinfo) // 数据库一条新纪录
...@@ -166,16 +165,16 @@ func SendFile(c echo.Context) error { ...@@ -166,16 +165,16 @@ func SendFile(c echo.Context) error {
info.FileType = "txt" info.FileType = "txt"
} }
if model.find(info.FileLink,info.SessionId,)==false{ if model.find(info.FileLink, info.SessionId) == false {
cookie,err:=c.Cookie(info.SessionId) cookie, err := c.Cookie(info.SessionId)
if err!=nil{ if err != nil {
return err return err
} }
if cookie.Value!=info.FileLink{ if cookie.Value != info.FileLink {
return err // you wenti return err // you wenti
} }
} }
filePath := "./files/" + info.FileType + "/" + info.FileName + "." + info.FileType filePath := "./files/" + info.FileType + "/" + info.FileName + "." + info.FileType
src, err := os.Open(filePath) src, err := os.Open(filePath)
if err != nil { 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