nc-photos/app/lib/file_extension.dart

16 lines
404 B
Dart
Raw Normal View History

import 'dart:io';
import 'package:mime/mime.dart';
2023-02-20 15:21:57 +01:00
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);
}