nc-photos/app/lib/file_extension.dart
2023-02-20 22:58:02 +08:00

15 lines
404 B
Dart

import 'dart:io';
import 'package:mime/mime.dart';
import 'package:path/path.dart' as path_lib;
extension FileExtension on File {
Future<String?> readMime() async {
final header = await openRead(0, defaultMagicNumbersMaxLength)
.expand((element) => element)
.toList();
return lookupMimeType(path, headerBytes: header);
}
String get filename => path_lib.basename(path);
}