uploadFinalize method

Future<UploadFinalize> uploadFinalize({
  1. required String mediaId,
  2. TransformResponse<UploadFinalize> transform = defaultUploadFinalizeTransform,
})

The FINALIZE command should be called after the entire media file is uploaded using APPEND commands. If and (only if) the response of the FINALIZE command contains a UploadFinalize.processinginfo field, it may also be necessary to use a STATUS command and wait for it to return success before proceeding to Tweet creation.

mediaId: The mediaId returned from the INIT command.

transform: Can be used to parse the request. By default, the response is parsed in an isolate.

See https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-upload-finalize.

Implementation

Future<UploadFinalize> uploadFinalize({
  required String mediaId,
  TransformResponse<UploadFinalize> transform =
      defaultUploadFinalizeTransform,
}) async {
  final body = <String, String>{}
    ..addParameter('command', 'FINALIZE')
    ..addParameter('media_id', mediaId);

  return client
      .post(
        Uri.https('upload.twitter.com', '1.1/media/upload.json'),
        body: body,
      )
      .then(transform);
}