From fc04e08873db508edda3c1f6d9f07b064dc66ca6 Mon Sep 17 00:00:00 2001 From: weisd Date: Thu, 18 Jul 2024 14:48:21 +0800 Subject: [PATCH] up log --- Cargo.lock | 1 + rustfs/Cargo.toml | 1 + rustfs/src/storage/ecfs.rs | 31 ++++++++++++++++++++++++------- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f0abf09a..c55451eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1091,6 +1091,7 @@ dependencies = [ "async-trait", "clap", "ecstore", + "http", "hyper-util", "s3s", "time", diff --git a/rustfs/Cargo.toml b/rustfs/Cargo.toml index 85538161..6d283c7e 100644 --- a/rustfs/Cargo.toml +++ b/rustfs/Cargo.toml @@ -21,3 +21,4 @@ s3s = "0.10.0" clap = { version = "4.5.7", features = ["derive"] } tracing-subscriber = { version = "0.3.18", features = ["env-filter", "time"] } hyper-util = { version = "0.1.5", features = ["tokio", "server-auto", "server-graceful"] } +http.workspace = true diff --git a/rustfs/src/storage/ecfs.rs b/rustfs/src/storage/ecfs.rs index ce59e115..20249144 100644 --- a/rustfs/src/storage/ecfs.rs +++ b/rustfs/src/storage/ecfs.rs @@ -1,5 +1,3 @@ -use std::fmt::Debug; - use ecstore::disk_api::DiskError; use ecstore::store_api::BucketOptions; use ecstore::store_api::CompletePart; @@ -8,6 +6,7 @@ use ecstore::store_api::MultipartUploadResult; use ecstore::store_api::ObjectOptions; use ecstore::store_api::PutObjReader; use ecstore::store_api::StorageAPI; +use http::header::HeaderValue; use s3s::dto::*; use s3s::s3_error; use s3s::S3Error; @@ -15,6 +14,7 @@ use s3s::S3ErrorCode; use s3s::S3Result; use s3s::S3; use s3s::{S3Request, S3Response}; +use std::fmt::Debug; use anyhow::Result; use ecstore::store::ECStore; @@ -123,6 +123,7 @@ impl S3 for FS { #[tracing::instrument] async fn get_object(&self, req: S3Request) -> S3Result> { + // mc get 3 let input = req.input; println!("get_object: {:?}", &input); @@ -166,12 +167,24 @@ impl S3 for FS { sse_customer_key, sse_customer_key_md5, version_id, - } = &req.input; + } = req.input; - let info = try_!(self.store.get_object_info(bucket, key, &ObjectOptions::default()).await); + let info = try_!(self.store.get_object_info(&bucket, &key, &ObjectOptions::default()).await); debug!("info {:?}", info); - let output = HeadObjectOutput { ..Default::default() }; + let content_type = { + let m = HeaderValue::from_static("hello"); + + ContentType::try_from_header_value(m)? + }; + + let output = HeadObjectOutput { + content_length: Some(try_!(i64::try_from(info.size))), + content_type: Some(content_type), + last_modified: Some(info.mod_time.into()), + // metadata: object_metadata, + ..Default::default() + }; Ok(S3Response::new(output)) } @@ -219,7 +232,7 @@ impl S3 for FS { body, bucket, key, - // metadata, + metadata, content_length, .. } = input; @@ -243,10 +256,14 @@ impl S3 for FS { &self, req: S3Request, ) -> S3Result> { - let CreateMultipartUploadInput { bucket, key, .. } = req.input; + let CreateMultipartUploadInput { + bucket, key, metadata, .. + } = req.input; // mc cp step 3 + debug!("create_multipart_upload meta {:?}", &metadata); + let MultipartUploadResult { upload_id, .. } = try_!( self.store .new_multipart_upload(&bucket, &key, &ObjectOptions::default())