FileMessageCreateParams.withFileBytes constructor

FileMessageCreateParams.withFileBytes(
  1. Uint8List fileBytes,
  2. {String? fileName,
  3. String? mimeType,
  4. String? data,
  5. String? customType,
  6. MentionType? mentionType,
  7. List<String>? mentionedUserIds,
  8. List<MessageMetaArray>? metaArrays,
  9. int? parentMessageId,
  10. bool? replyToChannel,
  11. PushNotificationDeliveryOption pushNotificationDeliveryOption = PushNotificationDeliveryOption.normal,
  12. bool isPinnedMessage = false}
)

withFileBytes

Implementation

FileMessageCreateParams.withFileBytes(
  Uint8List fileBytes, {
  String? fileName,
  String? mimeType,
  String? data,
  String? customType,
  MentionType? mentionType,
  List<String>? mentionedUserIds,
  List<MessageMetaArray>? metaArrays,
  int? parentMessageId,
  bool? replyToChannel,
  PushNotificationDeliveryOption pushNotificationDeliveryOption =
      PushNotificationDeliveryOption.normal,
  bool isPinnedMessage = false,
}) : super(
        data: data,
        customType: customType,
        mentionType: mentionType ?? MentionType.users,
        mentionedUserIds: mentionedUserIds,
        metaArrays: metaArrays,
        parentMessageId: parentMessageId,
        replyToChannel: replyToChannel ?? false,
        pushNotificationDeliveryOption: pushNotificationDeliveryOption,
        isPinnedMessage: isPinnedMessage,
      ) {
  String? fileMimeType = lookupMimeType('', headerBytes: fileBytes);
  if (fileMimeType != null) {
    mimeType = fileMimeType;
  } else if (mimeType == null) {
    sbLog.w(StackTrace.current, 'Unknown file mimeType');
  }

  fileInfo = FileInfo.fromFileBytes(
    fileBytes: fileBytes,
    fileName: fileName ?? 'file',
    mimeType: mimeType,
  );
}