From 177f16ba82c88fe4516ed0e7364db2e7a921640a Mon Sep 17 00:00:00 2001 From: Daniel Aloni Date: Thu, 23 May 2024 16:26:29 +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 f111b7a5..864a11a6 100644 --- a/api/r0/upload_async.go +++ b/api/r0/upload_async.go @@ -60,24 +60,30 @@ 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) r.Body = io.NopCloser(bytes.NewBuffer(buf)) 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 e9c2379d..7994c6dd 100644 --- a/api/r0/upload_sync.go +++ b/api/r0/upload_sync.go @@ -36,24 +36,30 @@ 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) r.Body = io.NopCloser(bytes.NewBuffer(buf)) 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.",