prepare get function for s3
This commit is contained in:
parent
2c28d69d55
commit
eaa79b749e
25
src/s3.rs
25
src/s3.rs
@ -1,10 +1,5 @@
|
||||
use minio::s3::{
|
||||
args::{BucketExistsArgs, MakeBucketArgs},
|
||||
client::ClientBuilder,
|
||||
creds::StaticProvider,
|
||||
error::Error,
|
||||
http::BaseUrl,
|
||||
Client,
|
||||
args::{BucketExistsArgs, MakeBucketArgs}, client::ClientBuilder, creds::StaticProvider, error::Error, http::BaseUrl, types::S3Api, Client
|
||||
};
|
||||
use tracing::{instrument, trace};
|
||||
use url::Url;
|
||||
@ -60,4 +55,22 @@ impl S3 {
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn _get(&self, name: &Url) -> Option<String> {
|
||||
if let Some(domain) = name.domain() {
|
||||
let filename = domain.to_string() + name.path();
|
||||
|
||||
let data = self
|
||||
.client
|
||||
.get_object(&self.bucket_name, &filename)
|
||||
.send()
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
if let Ok(segments )= data.content.to_segmented_bytes().await {
|
||||
return Some(segments.to_bytes().iter().map(|c| *c as char).collect::<String>())
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user