setContentTypeFromFile method
Set the content type given a file
Implementation
void setContentTypeFromFile(File file) {
final setContentType = headers.contentType;
if (setContentType == null || setContentType.mimeType == 'text/plain') {
final fileContentType = file.contentType;
if (fileContentType != null) {
headers.contentType = file.contentType;
} else {
final extension = file.path.split('.').last;
final suggestedMime = mimeFromExtension(extension);
if (suggestedMime != null) {
setContentTypeFromExtension(extension);
} else {
headers.contentType = ContentType.binary;
}
}
}
}