setThumbnailForPcEvent method

  1. @override
Future<NetworkResponse> setThumbnailForPcEvent(
  1. dynamic path,
  2. dynamic pcEventId
)
override

Implementation

@override
Future<NetworkResponse> setThumbnailForPcEvent(path, pcEventId) async {
  bool isDisconnect = await WifiService.isDisconnectWhenCallApi();
  if (isDisconnect) return NetworkResponse.withDisconnect();
  try {
    String fileName = path.split('/').last;
    FormData data = FormData.fromMap({
      'pcEventId': pcEventId,
      "fileName": MultipartFile.fromBytes(File(path).readAsBytesSync(),
          filename: fileName),
    });
    Response response = await AppClientsWeb(
            requiredToken: true, token: await appPrefs.getNormalToken())
        .post(AppEndpoint.setThumbnailForPcEvent(), data: data);
    return NetworkResponse.fromResponse(response,
        converter: (json) => json['fileName']);
  } on DioError catch (e) {
    appDebugPrint('DioError: $e');
    return NetworkResponse.withErrorRequest(e);
  } catch (e) {
    return NetworkResponse.withErrorConvert(e);
  }
}