Skip to content

Commit

Permalink
form-data 格式值不需要 encode
Browse files Browse the repository at this point in the history
  • Loading branch information
2betop committed Dec 9, 2019
1 parent c0ce3be commit 352eb5b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "amis",
"version": "1.0.7",
"version": "1.0.8",
"description": "一种MIS页面生成工具",
"main": "lib/index.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/renderers/Form/File.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ export default class FileControl extends React.Component<FileProps, FileState> {
.split('&')
.forEach(item => {
const parts = item.split('=');
fd.append(parts[0], parts[1]);
fd.append(parts[0], decodeURIComponent(parts[1]));
});

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

fd.append('key', state.key);
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/Form/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ export default class ImageControl extends React.Component<
.split('&')
.forEach(item => {
let parts = item.split('=');
fd.append(parts[0], parts[1]);
fd.append(parts[0], decodeURIComponent(parts[1]));
});
}

Expand Down
3 changes: 2 additions & 1 deletion src/utils/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,8 @@ export function object2formData(
.split('&')
.forEach(item => {
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;
}
Expand Down

0 comments on commit 352eb5b

Please sign in to comment.