form-data 格式值不需要 encode

This commit is contained in:
liaoxuezhi 2019-12-09 21:40:49 +08:00
parent c0ce3beb8a
commit 352eb5baf7
4 changed files with 6 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "amis", "name": "amis",
"version": "1.0.7", "version": "1.0.8",
"description": "一种MIS页面生成工具", "description": "一种MIS页面生成工具",
"main": "lib/index.js", "main": "lib/index.js",
"scripts": { "scripts": {

View File

@ -636,7 +636,7 @@ export default class FileControl extends React.Component<FileProps, FileState> {
.split('&') .split('&')
.forEach(item => { .forEach(item => {
const parts = item.split('='); const parts = item.split('=');
fd.append(parts[0], parts[1]); fd.append(parts[0], decodeURIComponent(parts[1]));
}); });
fd.append(config.fieldName || 'file', file); fd.append(config.fieldName || 'file', file);
@ -774,7 +774,7 @@ export default class FileControl extends React.Component<FileProps, FileState> {
.split('&') .split('&')
.forEach(item => { .forEach(item => {
const parts = item.split('='); const parts = item.split('=');
fd.append(parts[0], parts[1]); fd.append(parts[0], decodeURIComponent(parts[1]));
}); });
fd.append('key', state.key); fd.append('key', state.key);

View File

@ -743,7 +743,7 @@ export default class ImageControl extends React.Component<
.split('&') .split('&')
.forEach(item => { .forEach(item => {
let parts = item.split('='); let parts = item.split('=');
fd.append(parts[0], parts[1]); fd.append(parts[0], decodeURIComponent(parts[1]));
}); });
} }

View File

@ -1066,7 +1066,8 @@ export function object2formData(
.split('&') .split('&')
.forEach(item => { .forEach(item => {
let parts = item.split('='); let parts = item.split('=');
parts[0] && fd.append(parts[0], parts[1]); // form-data/multipart 是不需要 encode 值的。
parts[0] && fd.append(parts[0], decodeURIComponent(parts[1]));
}); });
return fd; return fd;
} }