uploadFile method
Future<T>
uploadFile({
- required TGUploadFileRequest request,
- dynamic onSuccess(
- dynamic T
- dynamic onError(
- dynamic E
Implementation
Future<T> uploadFile(
{required TGUploadFileRequest request,
onSuccess(T)?,
onError(E)?}) 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 _performCallbackForUploadFileResponse(httpRes, onError, onSuccess);
} catch (error) {
T t = _populateExceptionResponse(error);
onError!(t);
return t;
}
}