miguelpruivo/flutter_file_picker

The video extension is jpeg (ios)

Closed this issue · 5 comments

(ios) When selecting a video from the gallery and the video download from WhatsApp, the extension is entitled '.jpeg' and the video is not accepted for playback with this extension, and when dealing with it, it exits(crash) the application.

This issue is stale because it has been open for 14 days with no activity.

same issue. any solution for this?

@alim699 here is my temporary solution. this is not guaranteed solution but worked for me for all of my use cases

`

import 'dart:convert';
import 'package:mime/mime.dart';

Future checkAndFixFile(String path) async {
String mime = getFileMime(path);
if (mime.contains("image")) {
Uint8List fileData = await File(path).readAsBytes();
String fileBase64 = base64Encode(fileData.sublist(0, 5 * 1024)).substring(0, 250);
if (fileBase64.startsWith("AAAA") && fileData.length > 1 * 1024 * 1024) {
return await fixWhatsappVideo(fileData);
} else {
return path;
}
} else {
return path;
}
}

Future fixWhatsappVideo(Uint8List fileData) async {
var tempDir = await getTemporaryDirectory();
var time = DateTime.now().millisecondsSinceEpoch;
String filePath = '${tempDir.path}/$time.mp4';
await File(filePath).writeAsBytes(fileData);
return filePath;
}

`

This issue is stale because it has been open for 14 days with no activity.

This issue was closed because it has been inactive for 14 days since being marked as stale.