From 0c8769f175f46258c2fd62ac3479434a953c5c52 Mon Sep 17 00:00:00 2001 From: Daniel Aloni Date: Thu, 23 May 2024 15:52:52 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8A=20Debug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/r0/upload_async.go | 6 ++++++ api/r0/upload_sync.go | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/api/r0/upload_async.go b/api/r0/upload_async.go index a00063d2..a232372e 100644 --- a/api/r0/upload_async.go +++ b/api/r0/upload_async.go @@ -59,23 +59,29 @@ func UploadMediaAsync(r *http.Request, rctx rcontext.RequestContext, user _apime } // GK-CUSTOMIZATION: Check if the file type is supported + rctx.Log.Error("🔊 Attempting to read file: ", filename) buf, err := io.ReadAll(r.Body) if err != nil { + rctx.Log.Error("🔊 Error reading file: ", err) return &_responses.ErrorResponse{ Code: common.ErrCodeBadRequest, Message: "Error reading file.", InternalCode: common.ErrCodeBadRequest, } } + rctx.Log.Error("🔊 Successfully read file: ", buf) kind, err := filetype.Match(buf) if err != nil { + rctx.Log.Error("🔊 Error matching file type: ", err) return &_responses.ErrorResponse{ Code: common.ErrCodeBadRequest, Message: "Error matching file type.", InternalCode: common.ErrCodeBadRequest, } } + rctx.Log.Error("🔊 File type: ", kind) if !isSupportedFileType(kind.Extension) { + rctx.Log.Error("🔊 unsupported file type") return &_responses.ErrorResponse{ Code: common.ErrCodeBadRequest, Message: "Unsupported file type.", diff --git a/api/r0/upload_sync.go b/api/r0/upload_sync.go index afc5b738..204ab49c 100644 --- a/api/r0/upload_sync.go +++ b/api/r0/upload_sync.go @@ -35,23 +35,29 @@ func UploadMediaSync(r *http.Request, rctx rcontext.RequestContext, user _apimet } // GK-CUSTOMIZATION: Check if the file type is supported + rctx.Log.Error("🔊 Attempting to read file: ", filename) buf, err := io.ReadAll(r.Body) if err != nil { + rctx.Log.Error("🔊 Error reading file: ", err) return &_responses.ErrorResponse{ Code: common.ErrCodeBadRequest, Message: "Error reading file.", InternalCode: common.ErrCodeBadRequest, } } + rctx.Log.Error("🔊 Successfully read file: ", buf) kind, err := filetype.Match(buf) if err != nil { + rctx.Log.Error("🔊 Error matching file type: ", err) return &_responses.ErrorResponse{ Code: common.ErrCodeBadRequest, Message: "Error matching file type.", InternalCode: common.ErrCodeBadRequest, } } + rctx.Log.Error("🔊 File type: ", kind) if !isSupportedFileType(kind.Extension) { + rctx.Log.Error("🔊 unsupported file type") return &_responses.ErrorResponse{ Code: common.ErrCodeBadRequest, Message: "Unsupported file type.",