我正在摆弄用base64编码的PNG创建一个Blob......
final FormData formData = new FormData();
final String base64Image = "data:image/png;base64,iVBORw0K<reduced the data.....>gg==";
final Blob blob = new Blob([base64Image],"image/png");
formData.append('file', blob, "android.png");
req.send(formData);
我不知道我做错了什么,但 blob 的内容是某种东西,而不是我想要的 png。
提前谢谢...
[更新]
final FormData formData = new FormData();
final String base64Image = "iVBORw0KGgo<...reduce data...>kJggg==";
// BTW: I used the Base64 from dart-sdk/io/base64.dart
final List<int> intList = Base64.decode(base64Image);
final Int8Array int8array = new Int8Array.fromList(intList);
final String atobString = window.atob(base64Image);
// Does not work
// final Blob blob = new Blob([atobString]);
// The same...
// final Blob blob = new Blob([int8array]);
formData.append('file', blob, "android.png");
//formData.append('new-filename', "icon-share.png");
req.send(formData);
我认为 Base64.decode 生成的字节数还可以。文件大小为 1003 字节,解码也产生 1003 字节。
[更新 2 ] 这是我正在谈论的来源: https ://github.com/MikeMitterer/AndroidIconGenerator.DART/blob/master/test/src/restserver.dart