diff --git a/api/r0/upload_async.go b/api/r0/upload_async.go index 585903e3..a50a8671 100644 --- a/api/r0/upload_async.go +++ b/api/r0/upload_async.go @@ -2,12 +2,10 @@ package r0 import ( "errors" - "io" "net/http" "path/filepath" "github.com/getsentry/sentry-go" - "github.com/h2non/filetype" "github.com/sirupsen/logrus" "github.com/t2bot/matrix-media-repo/api/_apimeta" "github.com/t2bot/matrix-media-repo/api/_responses" @@ -59,15 +57,15 @@ func UploadMediaAsync(r *http.Request, rctx rcontext.RequestContext, user _apime } // GK-CUSTOMIZATION: Check if the file type is supported - buf, _ := io.ReadAll(r.Body) - kind, _ := filetype.Match(buf) - if !isSupportedFileType(kind.Extension) { - return &_responses.ErrorResponse{ - Code: common.ErrCodeBadRequest, - Message: "Unsupported file type.", - InternalCode: common.ErrCodeBadRequest, - } - } + // buf, _ := io.ReadAll(r.Body) + // kind, _ := filetype.Match(buf) + // if !isSupportedFileType(kind.Extension) { + // return &_responses.ErrorResponse{ + // Code: common.ErrCodeBadRequest, + // Message: "Unsupported file type.", + // InternalCode: common.ErrCodeBadRequest, + // } + // } rctx = rctx.LogWithFields(logrus.Fields{ "mediaId": mediaId, diff --git a/api/r0/upload_sync.go b/api/r0/upload_sync.go index 3dd33ac2..56c61f53 100644 --- a/api/r0/upload_sync.go +++ b/api/r0/upload_sync.go @@ -2,13 +2,11 @@ package r0 import ( "errors" - "io" "net/http" "path/filepath" "strconv" "github.com/getsentry/sentry-go" - "github.com/h2non/filetype" "github.com/sirupsen/logrus" "github.com/t2bot/matrix-media-repo/api/_apimeta" "github.com/t2bot/matrix-media-repo/api/_responses" @@ -35,15 +33,15 @@ func UploadMediaSync(r *http.Request, rctx rcontext.RequestContext, user _apimet } // GK-CUSTOMIZATION: Check if the file type is supported - buf, _ := io.ReadAll(r.Body) - kind, _ := filetype.Match(buf) - if !isSupportedFileType(kind.Extension) { - return &_responses.ErrorResponse{ - Code: common.ErrCodeBadRequest, - Message: "Unsupported file type.", - InternalCode: common.ErrCodeBadRequest, - } - } + // buf, _ := io.ReadAll(r.Body) + // kind, _ := filetype.Match(buf) + // if !isSupportedFileType(kind.Extension) { + // return &_responses.ErrorResponse{ + // Code: common.ErrCodeBadRequest, + // Message: "Unsupported file type.", + // InternalCode: common.ErrCodeBadRequest, + // } + // } rctx = rctx.LogWithFields(logrus.Fields{ "filename": filename,