todo:Error

This commit is contained in:
weisd
2024-07-02 17:01:54 +08:00
parent ace3fbdfa0
commit 5eb6d52daf
6 changed files with 50 additions and 45 deletions
+22
View File
@@ -1,14 +1,30 @@
use std::fmt::Debug;
use ecstore::store_api::ObjectOptions;
use ecstore::store_api::PutObjReader;
use ecstore::store_api::StorageAPI;
use s3s::dto::*;
use s3s::s3_error;
use s3s::S3Error;
use s3s::S3ErrorCode;
use s3s::S3Result;
use s3s::S3;
use s3s::{S3Request, S3Response};
use anyhow::Result;
use ecstore::store::ECStore;
use tracing::error;
macro_rules! try_ {
($result:expr) => {
match $result {
Ok(val) => val,
Err(err) => {
return Err(S3Error::with_message(S3ErrorCode::InternalError, format!("{}", err)));
}
}
};
}
#[derive(Debug)]
pub struct FS {
@@ -149,6 +165,12 @@ impl S3 for FS {
let Some(body) = body else { return Err(s3_error!(IncompleteBody)) };
let Some(content_length) = content_length else { return Err(s3_error!(IncompleteBody)) };
let reader = PutObjReader::new(body.into(), content_length as usize);
try_!(self.store.put_object(&bucket, &key, &reader, &ObjectOptions::default()).await);
// self.store.put_object(bucket, object, data, opts);
let output = PutObjectOutput { ..Default::default() };