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.",