Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TW-1806: add mimeType custom for fileInfo #62

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions lib/src/utils/models/file_info.dart
Original file line number Diff line number Diff line change
@@ -9,22 +9,23 @@ class FileInfo with EquatableMixin {
final String filePath;
final int fileSize;
final Stream<List<int>>? readStream;
final String? customMimeType;

FileInfo(
this.fileName,
this.filePath,
this.fileSize, {
this.readStream,
this.customMimeType,
});

factory FileInfo.empty() {
return FileInfo('', '', 0);
}

String get mimeType =>
lookupMimeType(filePath) ??
lookupMimeType(fileName) ??
'application/octet-stream';
customMimeType ?? lookupMimeType(filePath) ?? lookupMimeType(fileName) ?? 'application/octet-stream';


Map<String, dynamic> get metadata => ({
'mimetype': mimeType,
@@ -39,6 +40,7 @@ class FileInfo with EquatableMixin {
file.size,
width: file.info['w'],
height: file.info['h'],
customMimeType: file.mimeType,
);
} else if (file.msgType == MessageTypes.Video) {
return VideoFileInfo(
@@ -51,9 +53,10 @@ class FileInfo with EquatableMixin {
duration: file.info['duration'] != null && file.info['duration'] is int
? Duration(milliseconds: file.info['duration'])
: null,
customMimeType: file.mimeType,
);
}
return FileInfo(file.name, file.filePath ?? '', file.size);
return FileInfo(file.name, file.filePath ?? '', file.size, customMimeType: file.mimeType,);
}

@override
1 change: 1 addition & 0 deletions lib/src/utils/models/image_file_info.dart
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ class ImageFileInfo extends FileInfo {
super.filePath,
super.fileSize, {
super.readStream,
super.customMimeType,
this.width,
this.height,
}
1 change: 1 addition & 0 deletions lib/src/utils/models/video_file_info.dart
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ class VideoFileInfo extends FileInfo {
super.filePath,
super.fileSize, {
super.readStream,
super.customMimeType,
required this.imagePlaceholderBytes,
this.width,
this.height,