Fix the Bug in IE browser.
This commit is contained in:
parent
2f794f549f
commit
2027b2139c
@ -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 {
|
||||
|
@ -124,6 +124,7 @@ func (this *MatterService) Upload(file multipart.File, user *User, puuid string,
|
||||
panic("文件名不能超过200")
|
||||
}
|
||||
|
||||
|
||||
//获取文件应该存放在的物理路径的绝对路径和相对路径。
|
||||
absolutePath, relativePath := GetUserFilePath(user.Username, false)
|
||||
absolutePath = absolutePath + "/" + filename
|
||||
|
@ -122,6 +122,12 @@ func (this *Router) ServeHTTP(writer http.ResponseWriter, request *http.Request)
|
||||
path := request.URL.Path
|
||||
if strings.HasPrefix(path, "/api") {
|
||||
|
||||
//对于IE浏览器,会自动缓存,因此设置不缓存Header.
|
||||
writer.Header().Set("Pragma", "No-cache")
|
||||
writer.Header().Set("Cache-Control", "no-cache")
|
||||
writer.Header().Set("Expires", "0")
|
||||
|
||||
|
||||
if CONFIG.Installed {
|
||||
//已安装的模式
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user