postBytes method

  1. @override
Future<ParseNetworkResponse> postBytes(
  1. String path, {
  2. Stream<List<int>>? data,
  3. ParseNetworkOptions? options,
  4. ProgressCallback? onSendProgress,
  5. dynamic cancelToken,
})
override

Implementation

@override
Future<ParseNetworkResponse> postBytes(String path,
    {Stream<List<int>>? data,
    ParseNetworkOptions? options,
    ProgressCallback? onSendProgress,
    dynamic cancelToken}) async {
  try {
    final dio.Response<String> dioResponse = await _client.post<String>(
      path,
      data: data,
      cancelToken: cancelToken,
      options: _Options(headers: options?.headers),
      onSendProgress: onSendProgress,
    );

    return ParseNetworkResponse(
      data: dioResponse.data!,
      statusCode: dioResponse.statusCode!,
    );
  } on dio.DioException catch (error) {
    if (error.response != null) {
      return ParseNetworkResponse(
        data: error.response?.data ?? _fallbackErrorData,
        statusCode: error.response?.statusCode ?? ParseError.otherCause,
      );
    } else {
      return _getOtherCaseErrorForParseNetworkResponse(
          error.error.toString());
    }
  }
}