From babd795d792e95f6e708af6ee8207ef6877e2b32 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Tue, 20 Feb 2018 10:41:00 -0500 Subject: MM-9556 Added ability to upload files without a multipart request (#8306) * MM-9556 Added ability to upload files without a multipart request * MM-9556 Handled some unusual test behaviour --- api4/params.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'api4/params.go') diff --git a/api4/params.go b/api4/params.go index 30638578b..070efbbc6 100644 --- a/api4/params.go +++ b/api4/params.go @@ -27,6 +27,7 @@ type ApiParams struct { ChannelId string PostId string FileId string + Filename string PluginId string CommandId string HookId string @@ -54,6 +55,7 @@ func ApiParamsFromRequest(r *http.Request) *ApiParams { params := &ApiParams{} props := mux.Vars(r) + query := r.URL.Query() if val, ok := props["user_id"]; ok { params.UserId = val @@ -73,6 +75,8 @@ func ApiParamsFromRequest(r *http.Request) *ApiParams { if val, ok := props["channel_id"]; ok { params.ChannelId = val + } else { + params.ChannelId = query.Get("channel_id") } if val, ok := props["post_id"]; ok { @@ -83,6 +87,8 @@ func ApiParamsFromRequest(r *http.Request) *ApiParams { params.FileId = val } + params.Filename = query.Get("filename") + if val, ok := props["plugin_id"]; ok { params.PluginId = val } @@ -151,17 +157,17 @@ func ApiParamsFromRequest(r *http.Request) *ApiParams { params.ActionId = val } - if val, err := strconv.Atoi(r.URL.Query().Get("page")); err != nil || val < 0 { + if val, err := strconv.Atoi(query.Get("page")); err != nil || val < 0 { params.Page = PAGE_DEFAULT } else { params.Page = val } - if val, err := strconv.ParseBool(r.URL.Query().Get("permanent")); err != nil { + if val, err := strconv.ParseBool(query.Get("permanent")); err != nil { params.Permanent = val } - if val, err := strconv.Atoi(r.URL.Query().Get("per_page")); err != nil || val < 0 { + if val, err := strconv.Atoi(query.Get("per_page")); err != nil || val < 0 { params.PerPage = PER_PAGE_DEFAULT } else if val > PER_PAGE_MAXIMUM { params.PerPage = PER_PAGE_MAXIMUM @@ -169,7 +175,7 @@ func ApiParamsFromRequest(r *http.Request) *ApiParams { params.PerPage = val } - if val, err := strconv.Atoi(r.URL.Query().Get("logs_per_page")); err != nil || val < 0 { + if val, err := strconv.Atoi(query.Get("logs_per_page")); err != nil || val < 0 { params.LogsPerPage = LOGS_PER_PAGE_DEFAULT } else if val > LOGS_PER_PAGE_MAXIMUM { params.LogsPerPage = LOGS_PER_PAGE_MAXIMUM -- cgit v1.2.3-1-g7c22