Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

为什么dio的fromMap会将MultipartFile自动放入files字段中 #2261

Closed
tangdi0802 opened this issue Jul 2, 2024 · 1 comment
Closed

Comments

@tangdi0802
Copy link

Request Statement

在文件上传中,使用final formData = FormData.fromMap({
'file': MultipartFile.fromBytes(file.bytes!),
});
进行单文件上传,会将file自动塞入files字段中。导致后端无法解析到file字段。
能否添加一个标志,表示是否自动将file转化为files
这是dio FormData中的代码
if (fromMap != null) {
// Use [encodeMap] to recursively add fields and files.
// TODO(Alex): Write a proper/elegant implementation.
encodeMap(
fromMap,
(key, value) {
if (value is MultipartFile) {
files.add(MapEntry(key, value));
} else {
fields.add(MapEntry(key, value?.toString() ?? ''));
}
return null;
},
listFormat: listFormat,
encode: false,
);
}

Solution Brainstorm

No response

@tangdi0802 tangdi0802 added the s: feature This issue indicates a feature request label Jul 2, 2024
@AlexV525
Copy link
Member

AlexV525 commented Jul 2, 2024

Please submit issues using the correct issue template.

@AlexV525 AlexV525 closed this as not planned Won't fix, can't repro, duplicate, stale Jul 2, 2024
@AlexV525 AlexV525 added i: not following issue template and removed s: feature This issue indicates a feature request labels Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants