uploadFileSync method

Future<T> uploadFileSync({
  1. required TGUploadFileRequest request,
})

Implementation

Future<T> uploadFileSync({required TGUploadFileRequest request}) async {
  try {
    var multipartRequest = http.MultipartRequest(
        "POST",
        Uri.parse(TGRequest.prepareUrl(
            TGRequest.defaultBaseUrl, request.getUri())));
    multipartRequest.headers.addAll(request.headers()!);
    multipartRequest.fields.addAll(request.body());
    multipartRequest.files.addAll(request.files());
    StreamedResponse httpRes = await multipartRequest.send();
    return Future.value(_performCallbackForUploadFileSyncResponse(httpRes));
  } catch (error) {
    T t = _populateExceptionResponse(error);
    return Future.value(t);
  }
}