mirror of
https://github.com/rustfs/rustfs.git
synced 2026-01-17 01:30:33 +00:00
fix put_object content-length empty
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -2135,6 +2135,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"admin",
|
||||
"async-trait",
|
||||
"atoi",
|
||||
"axum",
|
||||
"bytes",
|
||||
"clap",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::path::PathBuf;
|
||||
|
||||
const GLOBAL_DIR_SUFFIX: &str = "__XLDIR__";
|
||||
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
pub const AMZ_OBJECT_TAGGING: &str = "X-Amz-Tagging";
|
||||
pub const AMZ_STORAGE_CLASS: &str = "x-amz-storage-class";
|
||||
pub const AMZ_DECODED_CONTENT_LENGTH: &str = "X-Amz-Decoded-Content-Length";
|
||||
|
||||
@@ -57,6 +57,7 @@ router = { version = "0.0.1", path = "../router" }
|
||||
matchit = "0.8.4"
|
||||
shadow-rs = "0.35.2"
|
||||
const-str = { version = "0.5.7", features = ["std", "proc"] }
|
||||
atoi = "2.0.0"
|
||||
|
||||
[build-dependencies]
|
||||
prost-build.workspace = true
|
||||
|
||||
@@ -588,7 +588,19 @@ impl S3 for FS {
|
||||
|
||||
let Some(body) = body else { return Err(s3_error!(IncompleteBody)) };
|
||||
|
||||
let content_length = content_length.unwrap_or_default();
|
||||
let content_length = match content_length {
|
||||
Some(c) => c,
|
||||
None => {
|
||||
if let Some(val) = req.headers.get(xhttp::AMZ_DECODED_CONTENT_LENGTH) {
|
||||
match atoi::atoi::<i64>(val.as_bytes()) {
|
||||
Some(x) => x,
|
||||
None => return Err(s3_error!(UnexpectedContent)),
|
||||
}
|
||||
} else {
|
||||
return Err(s3_error!(UnexpectedContent));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let mut reader = PutObjReader::new(body, content_length as usize);
|
||||
|
||||
@@ -677,7 +689,19 @@ impl S3 for FS {
|
||||
// let upload_id =
|
||||
|
||||
let body = body.ok_or_else(|| s3_error!(IncompleteBody))?;
|
||||
let content_length = content_length.unwrap_or_default();
|
||||
let content_length = match content_length {
|
||||
Some(c) => c,
|
||||
None => {
|
||||
if let Some(val) = req.headers.get(xhttp::AMZ_DECODED_CONTENT_LENGTH) {
|
||||
match atoi::atoi::<i64>(val.as_bytes()) {
|
||||
Some(x) => x,
|
||||
None => return Err(s3_error!(UnexpectedContent)),
|
||||
}
|
||||
} else {
|
||||
return Err(s3_error!(UnexpectedContent));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// mc cp step 4
|
||||
let mut data = PutObjReader::new(body, content_length as usize);
|
||||
|
||||
Reference in New Issue
Block a user