Open wrsilva opened 2 months ago
lookupMimeType is it possible to add support for extensions .XLS | .XLSX | .CSV ?
String mimeType = lookupMimeType('test', headerBytes: file.take(defaultMagicNumbersMaxLength).toList()) ?? '';
mimeType return null
What is returned from the file.take(defaultMagicNumbersMaxLength).toList())
? I'm not sure where file
is coming from. I don't think you're able to declare .take on a FileSystemEntity
lookupMimeType is it possible to add support for extensions .XLS | .XLSX | .CSV ?
String mimeType = lookupMimeType('test', headerBytes: file.take(defaultMagicNumbersMaxLength).toList()) ?? '';
mimeType return nullWhat is returned from the
file.take(defaultMagicNumbersMaxLength).toList())
? I'm not sure wherefile
is coming from. I don't think you're able to declare .take on a FileSystemEntity
The take method is used to select only the first defaultMagicNumbersMaxLength bytes of the file, converting them into a list, which is then passed to the lookupMimeType function to identify the file's MIME type. This improves the efficiency of the code, ensuring that only the necessary amount of data is processed.
By limiting the reading to the first bytes using take, the code avoids unnecessary reading of the entire file, which can be costly in terms of performance, especially for large files.
in magic_number no contains xml or csv https://github.com/dart-lang/mime/blob/b01c9a24e0991da479bd405138be3b3e403ff456/lib/src/magic_number.dart#L29
lookupMimeType is it possible to add support for extensions .XLS | .XLSX | .CSV ?
String mimeType = lookupMimeType('test', headerBytes: file.take(defaultMagicNumbersMaxLength).toList()) ?? '';
mimeType return null