mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-26 05:56:50 +00:00
todo: get_object_reader
This commit is contained in:
Generated
+2
@@ -318,6 +318,7 @@ dependencies = [
|
|||||||
"crc32fast",
|
"crc32fast",
|
||||||
"futures",
|
"futures",
|
||||||
"hex-simd",
|
"hex-simd",
|
||||||
|
"http",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"netif",
|
"netif",
|
||||||
"path-absolutize",
|
"path-absolutize",
|
||||||
@@ -1093,6 +1094,7 @@ dependencies = [
|
|||||||
"ecstore",
|
"ecstore",
|
||||||
"http",
|
"http",
|
||||||
"hyper-util",
|
"hyper-util",
|
||||||
|
"mime",
|
||||||
"s3s",
|
"s3s",
|
||||||
"time",
|
"time",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ base64-simd = "0.8.0"
|
|||||||
sha2 = "0.10.8"
|
sha2 = "0.10.8"
|
||||||
hex-simd = "0.8.0"
|
hex-simd = "0.8.0"
|
||||||
path-clean = "1.0.1"
|
path-clean = "1.0.1"
|
||||||
|
http.workspace = true
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
|
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
|
||||||
|
|||||||
+15
-2
@@ -1,4 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use http::HeaderMap;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -7,8 +8,8 @@ use crate::{
|
|||||||
format::{DistributionAlgoVersion, FormatV3},
|
format::{DistributionAlgoVersion, FormatV3},
|
||||||
set_disk::SetDisks,
|
set_disk::SetDisks,
|
||||||
store_api::{
|
store_api::{
|
||||||
BucketInfo, BucketOptions, CompletePart, FileInfo, MakeBucketOptions, MultipartUploadResult, ObjectInfo, ObjectOptions,
|
BucketInfo, BucketOptions, CompletePart, FileInfo, GetObjectReader, HTTPRangeSpec, MakeBucketOptions,
|
||||||
PartInfo, PutObjReader, StorageAPI,
|
MultipartUploadResult, ObjectInfo, ObjectOptions, PartInfo, PutObjReader, StorageAPI,
|
||||||
},
|
},
|
||||||
utils::hash,
|
utils::hash,
|
||||||
};
|
};
|
||||||
@@ -132,6 +133,18 @@ impl StorageAPI for Sets {
|
|||||||
async fn get_object_info(&self, bucket: &str, object: &str, opts: &ObjectOptions) -> Result<ObjectInfo> {
|
async fn get_object_info(&self, bucket: &str, object: &str, opts: &ObjectOptions) -> Result<ObjectInfo> {
|
||||||
self.get_disks_by_key(object).get_object_info(bucket, object, opts).await
|
self.get_disks_by_key(object).get_object_info(bucket, object, opts).await
|
||||||
}
|
}
|
||||||
|
async fn get_Object_reader(
|
||||||
|
&self,
|
||||||
|
bucket: &str,
|
||||||
|
object: &str,
|
||||||
|
range: HTTPRangeSpec,
|
||||||
|
h: HeaderMap,
|
||||||
|
opts: &ObjectOptions,
|
||||||
|
) -> Result<GetObjectReader> {
|
||||||
|
self.get_disks_by_key(object)
|
||||||
|
.get_Object_reader(bucket, object, range, h, opts)
|
||||||
|
.await
|
||||||
|
}
|
||||||
async fn put_object(&self, bucket: &str, object: &str, data: PutObjReader, opts: &ObjectOptions) -> Result<()> {
|
async fn put_object(&self, bucket: &str, object: &str, data: PutObjReader, opts: &ObjectOptions) -> Result<()> {
|
||||||
self.get_disks_by_key(object).put_object(bucket, object, data, opts).await
|
self.get_disks_by_key(object).put_object(bucket, object, data, opts).await
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-2
@@ -2,6 +2,7 @@ use std::collections::HashMap;
|
|||||||
|
|
||||||
use anyhow::{Error, Result};
|
use anyhow::{Error, Result};
|
||||||
|
|
||||||
|
use http::HeaderMap;
|
||||||
use s3s::{dto::StreamingBlob, Body};
|
use s3s::{dto::StreamingBlob, Body};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
@@ -14,8 +15,8 @@ use crate::{
|
|||||||
peer::{PeerS3Client, S3PeerSys},
|
peer::{PeerS3Client, S3PeerSys},
|
||||||
sets::Sets,
|
sets::Sets,
|
||||||
store_api::{
|
store_api::{
|
||||||
BucketInfo, BucketOptions, CompletePart, MakeBucketOptions, MultipartUploadResult, ObjectInfo, ObjectOptions, PartInfo,
|
BucketInfo, BucketOptions, CompletePart, GetObjectReader, HTTPRangeSpec, MakeBucketOptions, MultipartUploadResult,
|
||||||
PutObjReader, StorageAPI,
|
ObjectInfo, ObjectOptions, PartInfo, PutObjReader, StorageAPI,
|
||||||
},
|
},
|
||||||
store_init, utils,
|
store_init, utils,
|
||||||
};
|
};
|
||||||
@@ -160,6 +161,22 @@ impl StorageAPI for ECStore {
|
|||||||
|
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
async fn get_Object_reader(
|
||||||
|
&self,
|
||||||
|
bucket: &str,
|
||||||
|
object: &str,
|
||||||
|
range: HTTPRangeSpec,
|
||||||
|
h: HeaderMap,
|
||||||
|
opts: &ObjectOptions,
|
||||||
|
) -> Result<GetObjectReader> {
|
||||||
|
let object = utils::path::encode_dir_object(object);
|
||||||
|
|
||||||
|
if self.single_pool() {
|
||||||
|
return self.pools[0].get_Object_reader(bucket, object.as_str(), range, h, opts).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
async fn put_object(&self, bucket: &str, object: &str, data: PutObjReader, opts: &ObjectOptions) -> Result<()> {
|
async fn put_object(&self, bucket: &str, object: &str, data: PutObjReader, opts: &ObjectOptions) -> Result<()> {
|
||||||
// checkPutObjectArgs
|
// checkPutObjectArgs
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use http::HeaderMap;
|
||||||
use rmp_serde::Serializer;
|
use rmp_serde::Serializer;
|
||||||
use s3s::dto::StreamingBlob;
|
use s3s::dto::StreamingBlob;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@@ -236,6 +237,13 @@ impl PutObjReader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct GetObjectReader {
|
||||||
|
pub stream: StreamingBlob,
|
||||||
|
pub object_info: ObjectInfo,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct HTTPRangeSpec {}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ObjectOptions {
|
pub struct ObjectOptions {
|
||||||
// Use the maximum parity (N/2), used when saving server configuration files
|
// Use the maximum parity (N/2), used when saving server configuration files
|
||||||
@@ -302,6 +310,14 @@ pub trait StorageAPI {
|
|||||||
async fn make_bucket(&self, bucket: &str, opts: &MakeBucketOptions) -> Result<()>;
|
async fn make_bucket(&self, bucket: &str, opts: &MakeBucketOptions) -> Result<()>;
|
||||||
async fn get_bucket_info(&self, bucket: &str, opts: &BucketOptions) -> Result<BucketInfo>;
|
async fn get_bucket_info(&self, bucket: &str, opts: &BucketOptions) -> Result<BucketInfo>;
|
||||||
async fn get_object_info(&self, bucket: &str, object: &str, opts: &ObjectOptions) -> Result<ObjectInfo>;
|
async fn get_object_info(&self, bucket: &str, object: &str, opts: &ObjectOptions) -> Result<ObjectInfo>;
|
||||||
|
async fn get_Object_reader(
|
||||||
|
&self,
|
||||||
|
bucket: &str,
|
||||||
|
object: &str,
|
||||||
|
range: HTTPRangeSpec,
|
||||||
|
h: HeaderMap,
|
||||||
|
opts: &ObjectOptions,
|
||||||
|
) -> Result<GetObjectReader>;
|
||||||
async fn put_object(&self, bucket: &str, object: &str, data: PutObjReader, opts: &ObjectOptions) -> Result<()>;
|
async fn put_object(&self, bucket: &str, object: &str, data: PutObjReader, opts: &ObjectOptions) -> Result<()>;
|
||||||
async fn put_object_part(
|
async fn put_object_part(
|
||||||
&self,
|
&self,
|
||||||
|
|||||||
@@ -22,3 +22,4 @@ clap = { version = "4.5.7", features = ["derive"] }
|
|||||||
tracing-subscriber = { version = "0.3.18", features = ["env-filter", "time"] }
|
tracing-subscriber = { version = "0.3.18", features = ["env-filter", "time"] }
|
||||||
hyper-util = { version = "0.1.5", features = ["tokio", "server-auto", "server-graceful"] }
|
hyper-util = { version = "0.1.5", features = ["tokio", "server-auto", "server-graceful"] }
|
||||||
http.workspace = true
|
http.workspace = true
|
||||||
|
mime = "0.3.17"
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ use ecstore::store_api::MultipartUploadResult;
|
|||||||
use ecstore::store_api::ObjectOptions;
|
use ecstore::store_api::ObjectOptions;
|
||||||
use ecstore::store_api::PutObjReader;
|
use ecstore::store_api::PutObjReader;
|
||||||
use ecstore::store_api::StorageAPI;
|
use ecstore::store_api::StorageAPI;
|
||||||
use http::header::HeaderValue;
|
|
||||||
use s3s::dto::*;
|
use s3s::dto::*;
|
||||||
use s3s::s3_error;
|
use s3s::s3_error;
|
||||||
use s3s::S3Error;
|
use s3s::S3Error;
|
||||||
@@ -15,6 +14,7 @@ use s3s::S3Result;
|
|||||||
use s3s::S3;
|
use s3s::S3;
|
||||||
use s3s::{S3Request, S3Response};
|
use s3s::{S3Request, S3Response};
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use ecstore::store::ECStore;
|
use ecstore::store::ECStore;
|
||||||
@@ -172,11 +172,7 @@ impl S3 for FS {
|
|||||||
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);
|
debug!("info {:?}", info);
|
||||||
|
|
||||||
let content_type = {
|
let content_type = try_!(ContentType::from_str("application/x-msdownload"));
|
||||||
let m = HeaderValue::from_static("hello");
|
|
||||||
|
|
||||||
ContentType::try_from_header_value(m)?
|
|
||||||
};
|
|
||||||
|
|
||||||
let output = HeadObjectOutput {
|
let output = HeadObjectOutput {
|
||||||
content_length: Some(try_!(i64::try_from(info.size))),
|
content_length: Some(try_!(i64::try_from(info.size))),
|
||||||
|
|||||||
Reference in New Issue
Block a user