From 821ff036be4ff310162195c34a2aeb88601ec12f Mon Sep 17 00:00:00 2001 From: weisd Date: Wed, 15 Jan 2025 21:45:23 +0800 Subject: [PATCH] fix get s3 body bytes use store_all_unlimited --- rustfs/src/admin/handlers/group.rs | 9 +++++++-- rustfs/src/admin/handlers/service_account.rs | 9 +++++++-- rustfs/src/admin/handlers/user.rs | 4 ---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/rustfs/src/admin/handlers/group.rs b/rustfs/src/admin/handlers/group.rs index dee5c5155..6fb0bdc93 100644 --- a/rustfs/src/admin/handlers/group.rs +++ b/rustfs/src/admin/handlers/group.rs @@ -33,8 +33,13 @@ impl Operation for UpdateGroupMembers { async fn call(&self, req: S3Request, _params: Params<'_, '_>) -> S3Result> { warn!("handle UpdateGroupMembers"); - let Some(body) = req.input.bytes() else { - return Err(s3_error!(InvalidRequest, "get body failed")); + let mut input = req.input; + let body = match input.store_all_unlimited().await { + Ok(b) => b, + Err(e) => { + warn!("get body failed, e: {:?}", e); + return Err(s3_error!(InvalidRequest, "get body failed")); + } }; let args: GroupAddRemove = serde_json::from_slice(&body) diff --git a/rustfs/src/admin/handlers/service_account.rs b/rustfs/src/admin/handlers/service_account.rs index 3b86474f8..0d2a3c1d4 100644 --- a/rustfs/src/admin/handlers/service_account.rs +++ b/rustfs/src/admin/handlers/service_account.rs @@ -32,8 +32,13 @@ impl Operation for AddServiceAccount { }; let _is_owner = true; // 先按true处理,后期根据请求决定。 - let Some(body) = req.input.bytes() else { - return Err(s3_error!(InvalidRequest, "get body failed")); + let mut input = req.input; + let body = match input.store_all_unlimited().await { + Ok(b) => b, + Err(e) => { + warn!("get body failed, e: {:?}", e); + return Err(s3_error!(InvalidRequest, "get body failed")); + } }; let mut create_req: AddServiceAccountReq = diff --git a/rustfs/src/admin/handlers/user.rs b/rustfs/src/admin/handlers/user.rs index e6295a68f..829f22217 100644 --- a/rustfs/src/admin/handlers/user.rs +++ b/rustfs/src/admin/handlers/user.rs @@ -53,10 +53,6 @@ impl Operation for AddUser { } }; - // let Some(body) = req.input.bytes() else { - // return Err(s3_error!(InvalidRequest, "get body failed")); - // }; - // let body_bytes = decrypt_data(input_cred.secret_key.expose().as_bytes(), &body) // .map_err(|e| S3Error::with_message(S3ErrorCode::InvalidArgument, format!("decrypt_data err {}", e)))?;