class that downloads the attachments
This commit is contained in:
		
							parent
							
								
									b200b1e443
								
							
						
					
					
						commit
						f132ae69c1
					
				
					 1 changed files with 14 additions and 0 deletions
				
			
		
							
								
								
									
										14
									
								
								lib/attachmentDownload.dart
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								lib/attachmentDownload.dart
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -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<void> 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)
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue