Browse Source

fix(dynamite): Fix application/octet-stream encoding

Signed-off-by: jld3103 <jld3103yt@gmail.com>
pull/1136/head
jld3103 1 year ago
parent
commit
fe6bf418cf
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 9
      packages/dynamite/dynamite/lib/src/models/type_result/base.dart

9
packages/dynamite/dynamite/lib/src/models/type_result/base.dart

@ -30,7 +30,14 @@ class TypeResultBase extends TypeResult {
return '$object.toString()'; return '$object.toString()';
} }
case 'application/octet-stream': 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: default:
throw Exception('Can not encode mime type "$mimeType"'); throw Exception('Can not encode mime type "$mimeType"');
} }

Loading…
Cancel
Save