FileMessageParams.withFileBytes constructor
Implementation
FileMessageParams.withFileBytes(Uint8List data,
{String? name, String? fileExtensionType}) {
String fileType = "";
final mime = lookupMimeType('', headerBytes: data);
if (mime == null) {
if (fileExtensionType != null) {
fileType = fileExtensionType;
} else {
logger.e(StackTrace.current, "File Extension Type UNKNOWN");
throw Exception(
"File Extension Type UNKNOWN. Please include `fileExtensionType`");
}
} else {
fileType = mime;
}
uploadFile = FileInfo.fromBytes(
name: name ?? 'my_file',
fileBytes: data,
mimeType: fileType,
);
}