From 30adf3ca31cd1d79751102260a95145bd15ab968 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Sun, 24 Sep 2023 23:15:06 +0200 Subject: [PATCH] feat(dynamite): fully support mimeType application/octet-stream Signed-off-by: Nikolas Rimikis --- .../dynamite/lib/src/models/type_result/type_result.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/dynamite/dynamite/lib/src/models/type_result/type_result.dart b/packages/dynamite/dynamite/lib/src/models/type_result/type_result.dart index db2c66ef..46eb94ac 100644 --- a/packages/dynamite/dynamite/lib/src/models/type_result/type_result.dart +++ b/packages/dynamite/dynamite/lib/src/models/type_result/type_result.dart @@ -87,6 +87,11 @@ sealed class TypeResult { return 'json.encode($serialized)'; case 'application/x-www-form-urlencoded': return 'Uri(queryParameters: $serialized! as Map).query'; + case 'application/octet-stream': + if (className != 'Uint8List') { + throw Exception('octet-stream can only be applied to binary data. Expected Uint8List but got $className'); + } + return '$object as Uint8List'; default: throw Exception('Can not encode mime type "$mimeType"'); }