prepare get function for s3

This commit is contained in:
oliver 2024-11-12 21:19:05 -07:00
parent 2c28d69d55
commit eaa79b749e

View File

@ -1,10 +1,5 @@
use minio::s3::{ use minio::s3::{
args::{BucketExistsArgs, MakeBucketArgs}, args::{BucketExistsArgs, MakeBucketArgs}, client::ClientBuilder, creds::StaticProvider, error::Error, http::BaseUrl, types::S3Api, Client
client::ClientBuilder,
creds::StaticProvider,
error::Error,
http::BaseUrl,
Client,
}; };
use tracing::{instrument, trace}; use tracing::{instrument, trace};
use url::Url; use url::Url;
@ -60,4 +55,22 @@ impl S3 {
.unwrap(); .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
}
} }