checkIn method

Future<Attachment> checkIn(
  1. int id,
  2. int fileId,
  3. int version,
  4. File file,
)

Implementation

Future<Attachment> checkIn(int id, int fileId, int version, File file) async {
  final data = FormData();
  var fileName = file.path.split('/').last;
  fileName = DateFormat('yyMMddhhmmss').format(DateTime.now()) +
      fileName.substring(fileName.lastIndexOf('.'));
  data.files.add(MapEntry(
      fileName,
      await MultipartFile.fromFile(
        file.path,
        contentType: MediaType.parse(lookupMimeType(file.path) ?? ""),
      )));
  try {
    final response = await dio.put('/attachments/$id/$fileId/checkin',
        queryParameters: {'version': version}, data: data);
    return Attachment.fromJson(response.data);
  } on DioException catch (e) {
    _handleError(e);
    rethrow;
  }
}