resolveExtension static method

String resolveExtension({
  1. String? filePath,
  2. required MediaType mediaType,
})

Extension to store the file under: the real one from filePath when it is a known media type, otherwise the historical default for mediaType.

Implementation

static String resolveExtension({String? filePath, required MediaType mediaType}) {
  if (filePath != null) {
    final fromPath = extensionFromPath(filePath);
    if (fromPath != null) return fromPath;
  }
  return defaultExtensionFor(mediaType);
}