From fe6bf418cf40487b0ec2e8ffcb0e324e49525532 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Tue, 14 Nov 2023 06:56:16 +0100 Subject: [PATCH] fix(dynamite): Fix application/octet-stream encoding Signed-off-by: jld3103 --- .../dynamite/lib/src/models/type_result/base.dart | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/dynamite/dynamite/lib/src/models/type_result/base.dart b/packages/dynamite/dynamite/lib/src/models/type_result/base.dart index 215f0a4c..170d8569 100644 --- a/packages/dynamite/dynamite/lib/src/models/type_result/base.dart +++ b/packages/dynamite/dynamite/lib/src/models/type_result/base.dart @@ -30,7 +30,14 @@ class TypeResultBase extends TypeResult { return '$object.toString()'; } case 'application/octet-stream': - return 'utf8.encode($object) as Uint8List'; + switch (className) { + case 'Uint8List': + return object; + case 'String': + return '(utf8.encode($object) as Uint8List)'; + default: + throw Exception('"$mimeType" can only be Uint8List or String'); + } default: throw Exception('Can not encode mime type "$mimeType"'); }