WampFileMetadata.fromJson constructor
WampFileMetadata.fromJson(
- Map<String, dynamic> json
)
Implementation
factory WampFileMetadata.fromJson(Map<String, dynamic> json) {
if (json['version'] != 1) {
throw const FormatException('Unsupported file metadata version');
}
final custom = json['custom'];
if (custom != null && custom is! Map) {
throw const FormatException('File metadata custom must be an object');
}
return WampFileMetadata(
name: json['name'] as String? ?? '',
size: json['size'] as int? ?? -1,
chunkSize: json['chunk_size'] as int? ?? -1,
contentType: json['content_type'] as String?,
sha256Digest: json['sha256'] as String?,
custom: custom == null ? null : Map<String, dynamic>.from(custom as Map),
);
}