import '../../data/bean/upload_info.dart';

/// 文件资源工具类
class FileDataSourceUtil {
  /// 是否网络图片优先
  static final bool isNetworkPriority = false;

  /// 获取文件数据源的src
  static String getFileDataSourceSrc(UploadInfo info) {
    String remoteUrl = info.fileUrl ?? "";
    String localFilePath = info.filePath ?? "";

    // 优先使用远程Url，否则使用文件的绝对路径
    if (isNetworkPriority) {
      String src;
      if (remoteUrl.isNotEmpty) {
        src = remoteUrl;
      } else {
        src = localFilePath;
      }

      return src;
    } else {
      return localFilePath;
    }
  }
}
