P2: S3 Multipart Upload support complete
- InitiateMultipartUpload: POST /s3/multipart/:bucket/:key/init - UploadPart: PUT /s3/multipart/:bucket/:key/part - CompleteMultipartUpload: POST /s3/multipart/:bucket/:key/complete - AbortMultipartUpload: DELETE /s3/multipart/:bucket/:key/abort - In-memory upload tracking with once_cell::Lazy - Part files stored in temp dir during upload - Final file assembled on CompleteMultipartUpload - XML responses for all operations Tests: 293 passed, 0 failed
This commit is contained in:
@@ -76,3 +76,38 @@ pub fn list_objects_xml(bucket_name: &str, objects: &[Value]) -> (HeaderMap, Str
|
||||
|
||||
(headers, xml)
|
||||
}
|
||||
|
||||
pub fn initiate_multipart_upload_xml(bucket: &str, key: &str, upload_id: &str) -> (HeaderMap, String) {
|
||||
let mut headers = HeaderMap::new();
|
||||
headers.insert("Content-Type", "application/xml".parse().unwrap());
|
||||
|
||||
let xml = format!(
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
||||
<InitiateMultipartUploadResult xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">
|
||||
<Bucket>{}</Bucket>
|
||||
<Key>{}</Key>
|
||||
<UploadId>{}</UploadId>
|
||||
</InitiateMultipartUploadResult>",
|
||||
bucket, key, upload_id
|
||||
);
|
||||
|
||||
(headers, xml)
|
||||
}
|
||||
|
||||
pub fn complete_multipart_upload_xml(bucket: &str, key: &str, etag: &str) -> (HeaderMap, String) {
|
||||
let mut headers = HeaderMap::new();
|
||||
headers.insert("Content-Type", "application/xml".parse().unwrap());
|
||||
|
||||
let xml = format!(
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
||||
<CompleteMultipartUploadResult xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">
|
||||
<Location>http://localhost:11438/s3/{}/{}</Location>
|
||||
<Bucket>{}</Bucket>
|
||||
<Key>{}</Key>
|
||||
<ETag>{}</ETag>
|
||||
</CompleteMultipartUploadResult>",
|
||||
bucket, key, bucket, key, etag
|
||||
);
|
||||
|
||||
(headers, xml)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user