attachment.dart 780 B

123456789101112131415161718192021222324252627
  1. class Attachment {
  2. final String name;
  3. final String path;
  4. final int? size;
  5. final String? mimeType; // Add mimeType if available
  6. Attachment({required this.name, required this.path, this.size, this.mimeType});
  7. bool get isImage {
  8. final ext = link.split('.').last.toLowerCase();
  9. return ['jpg', 'jpeg', 'png', 'gif', 'webp'].contains(ext) ||
  10. (mimeType?.startsWith('image/') ?? false);
  11. }
  12. bool get isVideo {
  13. final ext = link.split('.').last.toLowerCase();
  14. return ['mp4', 'mov', 'webm', 'avi'].contains(ext) ||
  15. (mimeType?.startsWith('video/') ?? false);
  16. }
  17. String get link => 'https://kemono.su/data$path';
  18. factory Attachment.fromJson(Map<String, dynamic> json) => Attachment(
  19. name: json['name'],
  20. path: json['path'],
  21. );
  22. }