upload method
Future<T>
upload({
- required TGUploadRequest request,
- dynamic onSuccess(
- dynamic T
- dynamic onError(
- dynamic T
Implementation
Future<T> upload(
{required TGUploadRequest request, onSuccess(T)?, onError(T)?}) async {
try {
var multipartRequest = http.MultipartRequest(
"POST",
Uri.parse(TGRequest.prepareUrl(
TGRequest.defaultBaseUrl, request.getUri())));
multipartRequest.files.add(request.file());
StreamedResponse httpRes = await multipartRequest.send();
return _performCallbackForStreamedResponse(httpRes, onError, onSuccess);
} catch (error) {
T t = _populateExceptionResponse(error);
onError!(t);
return t;
}
}