From 352eb5baf74c1386bb262936753ca6a93e014aa4 Mon Sep 17 00:00:00 2001 From: liaoxuezhi Date: Mon, 9 Dec 2019 21:40:49 +0800 Subject: [PATCH] =?UTF-8?q?form-data=20=E6=A0=BC=E5=BC=8F=E5=80=BC?= =?UTF-8?q?=E4=B8=8D=E9=9C=80=E8=A6=81=20encode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/renderers/Form/File.tsx | 4 ++-- src/renderers/Form/Image.tsx | 2 +- src/utils/helper.ts | 3 ++- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 8263aa79..670e1933 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "amis", - "version": "1.0.7", + "version": "1.0.8", "description": "一种MIS页面生成工具", "main": "lib/index.js", "scripts": { diff --git a/src/renderers/Form/File.tsx b/src/renderers/Form/File.tsx index d96d9212..eb7789a4 100644 --- a/src/renderers/Form/File.tsx +++ b/src/renderers/Form/File.tsx @@ -636,7 +636,7 @@ export default class FileControl extends React.Component { .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); @@ -774,7 +774,7 @@ export default class FileControl extends React.Component { .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); diff --git a/src/renderers/Form/Image.tsx b/src/renderers/Form/Image.tsx index 1965d57c..7fc3e4ad 100644 --- a/src/renderers/Form/Image.tsx +++ b/src/renderers/Form/Image.tsx @@ -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])); }); } diff --git a/src/utils/helper.ts b/src/utils/helper.ts index 5f6661e5..fadb1986 100644 --- a/src/utils/helper.ts +++ b/src/utils/helper.ts @@ -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; }