diff --git a/services/blob/src/s3.rs b/services/blob/src/s3.rs --- a/services/blob/src/s3.rs +++ b/services/blob/src/s3.rs @@ -65,7 +65,15 @@ &self, s3_path: &S3Path, ) -> Result { - unimplemented!() + let response = self + .client + .head_object() + .bucket(s3_path.bucket_name.clone()) + .key(s3_path.object_name.clone()) + .send() + .await?; + + Ok(response) } /// Downloads object and retrieves data bytes within provided range @@ -77,12 +85,33 @@ s3_path: &S3Path, range: impl Into>, ) -> Result> { - unimplemented!() + let mut request = self + .client + .get_object() + .bucket(&s3_path.bucket_name) + .key(&s3_path.object_name); + + if let Some((from, to)) = range.into() { + let range = format!("bytes={}-{}", from, to); + request = request.range(range); + } + + let response = request.send().await?; + let data = response.body.collect().await?; + Ok(data.into_bytes().to_vec()) } /// Deletes object at provided path pub async fn delete_object(&self, s3_path: &S3Path) -> Result<()> { - unimplemented!() + self + .client + .delete_object() + .bucket(&s3_path.bucket_name) + .key(&s3_path.object_name) + .send() + .await?; + + Ok(()) } }