completeMultipartUpload method

Future<String> completeMultipartUpload(
  1. String bucket,
  2. String object,
  3. String uploadId,
  4. List<CompletedPart> parts,
)

Complete the multipart upload. After all the parts are uploaded issuing this call will aggregate the parts on the server into a single object.

Implementation

Future<String> completeMultipartUpload(
  String bucket,
  String object,
  String uploadId,
  List<CompletedPart> parts,
) async {
  MinioInvalidBucketNameError.check(bucket);
  MinioInvalidObjectNameError.check(object);

  final queries = {'uploadId': uploadId};
  final payload = CompleteMultipartUpload(parts).toXml().toString();

  final resp = await _client.request(
    method: 'POST',
    bucket: bucket,
    object: object,
    queries: queries,
    payload: payload,
  );
  validate(resp, expect: 200);

  final node = xml.XmlDocument.parse(resp.body);
  final errorNode = node.findAllElements('Error');
  if (errorNode.isNotEmpty) {
    final error = Error.fromXml(errorNode.first);
    throw MinioS3Error(error.message, error, resp);
  }

  final etag = node.findAllElements('ETag').first.innerText;
  return etag;
}