FileMessageParams.withFile constructor
NOTE: Not supported for Web
Implementation
FileMessageParams.withFile(File file, {String? name}) {
if (kIsWeb) {
throw SBError(
message: "`FileMessageParams.withFile` is not supported for web",
);
}
String fileType;
if (lookupMimeType(file.path) == null) {
switch (getFileExtension(file.path)) {
case '.HEIC':
fileType = 'imgae/heic';
break;
case '.HEIF':
fileType = 'imgae/heif';
break;
default:
throw SBError(message: 'Unknown File Type');
}
} else {
fileType = lookupMimeType(file.path)!;
}
uploadFile = FileInfo.fromData(
name: name ?? 'my_file',
file: file,
mimeType: fileType,
);
}