From 87a3b550d14d8642bcb1a377a11efcde2716b794 Mon Sep 17 00:00:00 2001 From: YuuinIH <37664092+YuuinIH@users.noreply.github.com> Date: Sun, 12 Jun 2022 13:50:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E4=B8=8A=E4=BC=A0=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/controller/publish.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/controller/publish.go b/internal/controller/publish.go index 30fae86..54e9f3c 100644 --- a/internal/controller/publish.go +++ b/internal/controller/publish.go @@ -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,