File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,8 @@ class DefaultWnUtils implements WnUtils {
5555
5656 @override
5757 Future <String > getDefaultBlossomServerUrl () {
58- return getDefaultBlossomServerUrl ();
58+ // TODO: Replace with the actual implementation (e.g., read from settings).
59+ throw UnimplementedError ('getDefaultBlossomServerUrl not implemented' );
5960 }
6061}
6162
Original file line number Diff line number Diff line change @@ -9,15 +9,21 @@ class ImageUtils {
99 static Future <String ?> getMimeTypeFromPath (String filePath) async {
1010 try {
1111 final file = File (filePath);
12- if (! file.existsSync ()) {
13- _logger.warning ('File does not exist: $filePath , defaulting to image/jpeg' );
12+ final fileExists = file.existsSync ();
13+ if (! fileExists) {
14+ _logger.warning ('File does not exist: $filePath ' );
1415 return null ;
1516 }
16-
17- final mimeType = lookupMimeType (filePath);
17+ List <int >? headerBytes;
18+ try {
19+ headerBytes = await file.openRead (0 , 12 ).first;
20+ } catch (_) {
21+ // best-effort; fall back to extension-only detection
22+ }
23+ final mimeType = lookupMimeType (filePath, headerBytes: headerBytes);
1824 return mimeType;
19- } catch (e) {
20- _logger.severe ('Error reading file for MIME type detection: $filePath , error: $ e ' );
25+ } catch (e, st ) {
26+ _logger.severe ('Error reading file for MIME type detection: $filePath ' , e, st );
2127 return null ;
2228 }
2329 }
You can’t perform that action at this time.
0 commit comments