Skip to content

Commit

Permalink
feat:上传类型校验
Browse files Browse the repository at this point in the history
  • Loading branch information
YuuinIH committed Jun 12, 2022
1 parent 5fe9596 commit 87a3b55
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/controller/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@ func (ctl *Controller) Publish(c *gin.Context) {
return
}
title := c.PostForm("title")
// TODO: 判断文件类型是否为视频文件
if data.Header.Get("Content-Type") != "video/mp4" {
ctl.logger.Sugar().Errorf("data.Header.Get(Content-Type) error: %v", err)
c.JSON(http.StatusBadRequest, service.Response{
StatusCode: -1,
StatusMsg: errorx.ErrReadVideo.Error(),
})
return
}
res := ctl.service.PublishVideo(context.Background(), uc.UserID, data.Filename, file, title)
c.JSON(http.StatusOK, service.Response{
StatusCode: res.StatusCode,
Expand Down

0 comments on commit 87a3b55

Please sign in to comment.