Fix the Bug in IE browser.

This commit is contained in:
zicla
2018-12-11 01:36:53 +08:00
parent 2f794f549f
commit 2027b2139c
3 changed files with 26 additions and 2 deletions

View File

@ -274,7 +274,18 @@ func (this *MatterController) Upload(writer http.ResponseWriter, request *http.R
this.PanicError(err)
defer file.Close()
matter := this.matterService.Upload(file, user, puuid, handler.Filename, privacy, alien)
//对于IE浏览器filename可能包含了路径。
fileName := handler.Filename
pos := strings.LastIndex(fileName, "\\")
if pos != -1 {
fileName = fileName[pos+1:]
}
pos = strings.LastIndex(fileName, "/")
if pos != -1 {
fileName = fileName[pos+1:]
}
matter := this.matterService.Upload(file, user, puuid, fileName, privacy, alien)
return this.Success(matter)
}
@ -333,7 +344,7 @@ func (this *MatterController) Delete(writer http.ResponseWriter, request *http.R
this.PanicBadRequest("文件的uuid必填")
}
matter := this.matterDao.FindByUuid(uuid)
matter := this.matterDao.CheckByUuid(uuid)
//判断文件的所属人是否正确
user := this.checkUser(writer, request)
@ -360,6 +371,12 @@ func (this *MatterController) DeleteBatch(writer http.ResponseWriter, request *h
matter := this.matterDao.FindByUuid(uuid)
//如果matter已经是nil了直接跳过
if matter == nil {
this.logger.Warn("%s 对应的文件记录已经不存在了", uuid)
continue
}
//判断文件的所属人是否正确
user := this.checkUser(writer, request)
if user.Role != USER_ROLE_ADMINISTRATOR && matter.UserUuid != user.Uuid {