Loading crates/s3s-fs/src/s3.rs +47 −0 Original line number Diff line number Diff line Loading @@ -477,6 +477,53 @@ impl S3 for FileSystem { Ok(S3Response::new(output)) } #[tracing::instrument] async fn list_parts(&self, req: S3Request<ListPartsInput>) -> S3Result<S3Response<ListPartsOutput>> { let ListPartsInput { bucket, key, upload_id, .. } = req.input; let mut parts: Vec<Part> = Vec::new(); let mut iter = try_!(fs::read_dir(&self.root).await); let prefix = format!(".upload_id-{upload_id}"); while let Some(entry) = try_!(iter.next_entry().await) { let file_type = try_!(entry.file_type().await); if file_type.is_file().not() { continue; } let file_name = entry.file_name(); let Some(name) = file_name.to_str() else { continue }; let Some(part_segment) = name.strip_prefix(&prefix) else { continue }; let Some(part_number) = part_segment.strip_prefix(".part-") else { continue }; let part_number = part_number.parse::<i32>().unwrap(); let file_meta = try_!(entry.metadata().await); let last_modified = Timestamp::from(try_!(file_meta.modified())); let size = try_!(i64::try_from(file_meta.len())); let part = Part { last_modified: Some(last_modified), part_number, size, ..Default::default() }; parts.push(part); } let output = ListPartsOutput { bucket: Some(bucket), key: Some(key), upload_id: Some(upload_id), parts: Some(parts), ..Default::default() }; Ok(S3Response::new(output)) } #[tracing::instrument] async fn complete_multipart_upload( &self, Loading Loading
crates/s3s-fs/src/s3.rs +47 −0 Original line number Diff line number Diff line Loading @@ -477,6 +477,53 @@ impl S3 for FileSystem { Ok(S3Response::new(output)) } #[tracing::instrument] async fn list_parts(&self, req: S3Request<ListPartsInput>) -> S3Result<S3Response<ListPartsOutput>> { let ListPartsInput { bucket, key, upload_id, .. } = req.input; let mut parts: Vec<Part> = Vec::new(); let mut iter = try_!(fs::read_dir(&self.root).await); let prefix = format!(".upload_id-{upload_id}"); while let Some(entry) = try_!(iter.next_entry().await) { let file_type = try_!(entry.file_type().await); if file_type.is_file().not() { continue; } let file_name = entry.file_name(); let Some(name) = file_name.to_str() else { continue }; let Some(part_segment) = name.strip_prefix(&prefix) else { continue }; let Some(part_number) = part_segment.strip_prefix(".part-") else { continue }; let part_number = part_number.parse::<i32>().unwrap(); let file_meta = try_!(entry.metadata().await); let last_modified = Timestamp::from(try_!(file_meta.modified())); let size = try_!(i64::try_from(file_meta.len())); let part = Part { last_modified: Some(last_modified), part_number, size, ..Default::default() }; parts.push(part); } let output = ListPartsOutput { bucket: Some(bucket), key: Some(key), upload_id: Some(upload_id), parts: Some(parts), ..Default::default() }; Ok(S3Response::new(output)) } #[tracing::instrument] async fn complete_multipart_upload( &self, Loading