getContentName static method

String? getContentName({
  1. required Map headers,
})

Implementation

static String? getContentName({
  required Map headers,
}) {
  try {
    final res = (headers["content-disposition"] as String).split(";");

    for (final element in res) {
      if (element.contains('filename')) {
        final result =
            element.substring(element.indexOf("=") + 2, element.length - 1);
        try {
          return Uri.decodeFull(result);
        } catch (e) {
          try {
            return json.decode(result);
          } catch (e) {
            return result;
          }
        }
      }
    }
  } catch (e) {}
  return null;
}