File tree 2 files changed +25
-0
lines changed 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -538,6 +538,16 @@ impl S3Client {
538
538
upload_id : & str ,
539
539
parts : Vec < PartId > ,
540
540
) -> Result < PutResult > {
541
+ let parts = if parts. is_empty ( ) {
542
+ // If no parts were uploaded, upload an empty part
543
+ // otherwise the completion request will fail
544
+ let part = self
545
+ . put_part ( location, & upload_id. to_string ( ) , 0 , Bytes :: new ( ) )
546
+ . await ?;
547
+ vec ! [ part]
548
+ } else {
549
+ parts
550
+ } ;
541
551
let request = CompleteMultipartUpload :: from ( parts) ;
542
552
let body = quick_xml:: se:: to_string ( & request) . unwrap ( ) ;
543
553
Original file line number Diff line number Diff line change @@ -2200,6 +2200,21 @@ mod tests {
2200
2200
2201
2201
let meta = storage. head ( & path) . await . unwrap ( ) ;
2202
2202
assert_eq ! ( meta. size, chunk_size * 2 ) ;
2203
+
2204
+ // Empty case
2205
+ let path = Path :: from ( "test_empty_multipart" ) ;
2206
+
2207
+ let id = multipart. create_multipart ( & path) . await . unwrap ( ) ;
2208
+
2209
+ let parts = vec ! [ ] ;
2210
+
2211
+ multipart
2212
+ . complete_multipart ( & path, & id, parts)
2213
+ . await
2214
+ . unwrap ( ) ;
2215
+
2216
+ let meta = storage. head ( & path) . await . unwrap ( ) ;
2217
+ assert_eq ! ( meta. size, 0 ) ;
2203
2218
}
2204
2219
2205
2220
#[ cfg( any( feature = "azure" , feature = "aws" ) ) ]
You can’t perform that action at this time.
0 commit comments