From f132ae69c1f298e9d59d9c0021c45ce1bc47ca1b Mon Sep 17 00:00:00 2001 From: juan Date: Wed, 23 Apr 2025 15:54:56 -0400 Subject: [PATCH] class that downloads the attachments --- lib/attachmentDownload.dart | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 lib/attachmentDownload.dart diff --git a/lib/attachmentDownload.dart b/lib/attachmentDownload.dart new file mode 100644 index 0000000..4fc4639 --- /dev/null +++ b/lib/attachmentDownload.dart @@ -0,0 +1,14 @@ +import 'dart:html' as html; +import 'dart:io'; +import 'structs.dart'; +import 'package:file_saver/file_saver.dart'; + +class Attachmentdownload { + Future saveFile(AttachmentResponse attachment) async { + await FileSaver.instance.saveFile( + name: attachment.name.toString().substring(0, attachment.name.toString().lastIndexOf('.')), + bytes: attachment.data, + ext: attachment.name.toString().substring(attachment.name.toString().lastIndexOf('.')+1) + ); + } +}