addThumbnailUrlForCat method

  1. @override
Future<NetworkResponse> addThumbnailUrlForCat(
  1. dynamic bytes,
  2. dynamic filePath,
  3. dynamic label,
  4. dynamic catId,
)
override

Implementation

@override
Future<NetworkResponse> addThumbnailUrlForCat(
    bytes, filePath, label, catId) async {
  bool isDisconnect = await WifiService.isDisconnect();
  if (isDisconnect) return NetworkResponse.withDisconnect();
  try {
    String fileName = filePath.split('/').last;
    FormData formData = FormData.fromMap({
      "fileName": MultipartFile.fromBytes(bytes, filename: fileName),
      "label": label,
      "catId": catId,
    });
    Response response = await AppClientsWeb(
            requiredToken: true, token: await appPrefs.getNormalToken())
        .post(AppEndpoint.addThumbnailUrlForCat(), data: formData);
    return NetworkResponse.fromResponse(response,
        converter: (json) => ThumbnailUrlOfCat.fromJson(json));
  } on DioError catch (e) {
    return NetworkResponse.withErrorRequest(e);
  }
}