AttachmentBuilder.file constructor

AttachmentBuilder.file(
  1. File file,
  2. {String? name,
  3. bool? spoiler}
)

Create attachment from specified file instance. Name will be automatically extracted from path if no name provided.

Implementation

factory AttachmentBuilder.file(File file, {String? name, bool? spoiler}) {
  final bytes = file.readAsBytesSync();
  final fileName = name ?? path_utils.basename(file.path);

  return AttachmentBuilder._new(bytes, fileName, spoiler);
}