1
0
Fork 0
mirror of https://gitlab.com/nkming2/nc-photos.git synced 2025-03-11 09:48:53 +01:00
nc-photos/app/lib/file_extension.dart

16 lines
404 B
Dart
Raw Normal View History

import 'dart:io';
import 'package:path/path.dart' as path_lib;
import 'package:mime/mime.dart';
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);
}