encode method
Implementation
@override
Future<Map<String, dynamic>> encode(dynamic content) async {
if (content is! RemoteAttachmentContent) {
throw const FormatException('Content must be RemoteAttachmentContent');
}
if (!content.url.startsWith('http')) {
throw Exception('Scheme must be http or https');
}
final scheme = Uri.parse(content.url).scheme; // 'http' or 'https'
final parameters = {
'contentDigest': content.contentDigest,
'salt': bytesToHex(content.salt, include0x: false),
'nonce': bytesToHex(content.nonce, include0x: false),
'secret': bytesToHex(content.secret, include0x: false),
'scheme': scheme,
'contentLength': content.contentLength.toString(),
'filename': content.filename,
};
if (content.description != null && content.description!.isNotEmpty) {
parameters['description'] = content.description!;
}
return {
'content': utf8.encode(content.url),
'parameters': parameters,
};
}