import 'dart:io';

import 'package:injectable/injectable.dart';
import '../../utils/http_handler.dart';
import '../api/atmob_file_api.dart';
import '../api/request/upload_request.dart';
import '../api/response/upload_result_bean.dart';

/// 亲密度分析Repository层
@LazySingleton()
class FileUploadRepository {
  final String tag = "FileUploadRepository";

  /// 文件上传接口
  AtmobFileApi atmobFileApi;

  FileUploadRepository(this.atmobFileApi);

  /// 上传图片
  Future<UploadResultBean> uploadImage({required File file}) async {
    return atmobFileApi
        .uploadImage(UploadRequest(file: file))
        .then(HttpHandler.handle(false));
  }
}
