mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-24 13:16:28 +00:00
fix (#682)
This commit is contained in:
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
use crate::auth::get_condition_values;
|
use crate::auth::get_condition_values;
|
||||||
use crate::error::ApiError;
|
use crate::error::ApiError;
|
||||||
use crate::storage::options::get_content_sha256;
|
use crate::storage::options::{filter_object_metadata, get_content_sha256};
|
||||||
use crate::storage::{
|
use crate::storage::{
|
||||||
access::{ReqInfo, authorize_request},
|
access::{ReqInfo, authorize_request},
|
||||||
options::{
|
options::{
|
||||||
@@ -97,9 +97,7 @@ use rustfs_targets::{
|
|||||||
EventName,
|
EventName,
|
||||||
arn::{TargetID, TargetIDError},
|
arn::{TargetID, TargetIDError},
|
||||||
};
|
};
|
||||||
use rustfs_utils::http::{
|
use rustfs_utils::http::{AMZ_CHECKSUM_MODE, AMZ_CHECKSUM_TYPE};
|
||||||
AMZ_CHECKSUM_MODE, AMZ_CHECKSUM_TYPE, AMZ_META_UNENCRYPTED_CONTENT_LENGTH, AMZ_META_UNENCRYPTED_CONTENT_MD5,
|
|
||||||
};
|
|
||||||
use rustfs_utils::{
|
use rustfs_utils::{
|
||||||
CompressionAlgorithm,
|
CompressionAlgorithm,
|
||||||
http::{
|
http::{
|
||||||
@@ -109,7 +107,6 @@ use rustfs_utils::{
|
|||||||
path::{is_dir_object, path_join_buf},
|
path::{is_dir_object, path_join_buf},
|
||||||
};
|
};
|
||||||
use rustfs_zip::CompressionFormat;
|
use rustfs_zip::CompressionFormat;
|
||||||
use s3s::header::{X_AMZ_OBJECT_LOCK_MODE, X_AMZ_OBJECT_LOCK_RETAIN_UNTIL_DATE};
|
|
||||||
use s3s::{S3, S3Error, S3ErrorCode, S3Request, S3Response, S3Result, dto::*, s3_error};
|
use s3s::{S3, S3Error, S3ErrorCode, S3Request, S3Response, S3Result, dto::*, s3_error};
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
@@ -4953,34 +4950,6 @@ pub(crate) async fn has_replication_rules(bucket: &str, objects: &[ObjectToDelet
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
fn filter_object_metadata(metadata: &HashMap<String, String>) -> Option<HashMap<String, String>> {
|
|
||||||
let mut filtered_metadata = HashMap::new();
|
|
||||||
for (k, v) in metadata {
|
|
||||||
if k.starts_with(RESERVED_METADATA_PREFIX_LOWER) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if v.is_empty() && (k == &X_AMZ_OBJECT_LOCK_MODE.to_string() || k == &X_AMZ_OBJECT_LOCK_RETAIN_UNTIL_DATE.to_string()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if k == AMZ_META_UNENCRYPTED_CONTENT_MD5 || k == AMZ_META_UNENCRYPTED_CONTENT_LENGTH {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// let lower_key = k.to_ascii_lowercase();
|
|
||||||
// if lower_key.starts_with("x-amz-meta-") || lower_key.starts_with("x-rustfs-meta-") {
|
|
||||||
// filtered_metadata.insert(lower_key, v.to_string());
|
|
||||||
// }
|
|
||||||
|
|
||||||
filtered_metadata.insert(k.clone(), v.clone());
|
|
||||||
}
|
|
||||||
if filtered_metadata.is_empty() {
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(filtered_metadata)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ use http::{HeaderMap, HeaderValue};
|
|||||||
use rustfs_ecstore::bucket::versioning_sys::BucketVersioningSys;
|
use rustfs_ecstore::bucket::versioning_sys::BucketVersioningSys;
|
||||||
use rustfs_ecstore::error::Result;
|
use rustfs_ecstore::error::Result;
|
||||||
use rustfs_ecstore::error::StorageError;
|
use rustfs_ecstore::error::StorageError;
|
||||||
|
use rustfs_utils::http::AMZ_META_UNENCRYPTED_CONTENT_LENGTH;
|
||||||
|
use rustfs_utils::http::AMZ_META_UNENCRYPTED_CONTENT_MD5;
|
||||||
|
use s3s::header::X_AMZ_OBJECT_LOCK_MODE;
|
||||||
|
use s3s::header::X_AMZ_OBJECT_LOCK_RETAIN_UNTIL_DATE;
|
||||||
|
|
||||||
use crate::auth::UNSIGNED_PAYLOAD;
|
use crate::auth::UNSIGNED_PAYLOAD;
|
||||||
use crate::auth::UNSIGNED_PAYLOAD_TRAILER;
|
use crate::auth::UNSIGNED_PAYLOAD_TRAILER;
|
||||||
@@ -326,6 +330,39 @@ pub fn extract_metadata_from_mime_with_object_name(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn filter_object_metadata(metadata: &HashMap<String, String>) -> Option<HashMap<String, String>> {
|
||||||
|
let mut filtered_metadata = HashMap::new();
|
||||||
|
for (k, v) in metadata {
|
||||||
|
if k.starts_with(RESERVED_METADATA_PREFIX_LOWER) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if v.is_empty() && (k == &X_AMZ_OBJECT_LOCK_MODE.to_string() || k == &X_AMZ_OBJECT_LOCK_RETAIN_UNTIL_DATE.to_string()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if k == AMZ_META_UNENCRYPTED_CONTENT_MD5 || k == AMZ_META_UNENCRYPTED_CONTENT_LENGTH {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let lower_key = k.to_ascii_lowercase();
|
||||||
|
if let Some(key) = lower_key.strip_prefix("x-amz-meta-") {
|
||||||
|
filtered_metadata.insert(key.to_string(), v.to_string());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if let Some(key) = lower_key.strip_prefix("x-rustfs-meta-") {
|
||||||
|
filtered_metadata.insert(key.to_string(), v.to_string());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
filtered_metadata.insert(k.clone(), v.clone());
|
||||||
|
}
|
||||||
|
if filtered_metadata.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(filtered_metadata)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Detects content type from object name based on file extension.
|
/// Detects content type from object name based on file extension.
|
||||||
pub(crate) fn detect_content_type_from_object_name(object_name: &str) -> String {
|
pub(crate) fn detect_content_type_from_object_name(object_name: &str) -> String {
|
||||||
let lower_name = object_name.to_lowercase();
|
let lower_name = object_name.to_lowercase();
|
||||||
|
|||||||
Reference in New Issue
Block a user