diff --git a/components/upload/__tests__/__snapshots__/demo.test.js.snap b/components/upload/__tests__/__snapshots__/demo.test.js.snap index bd12cf0538..19e05b31ce 100644 --- a/components/upload/__tests__/__snapshots__/demo.test.js.snap +++ b/components/upload/__tests__/__snapshots__/demo.test.js.snap @@ -118,6 +118,20 @@ exports[`renders ./components/upload/demo/defaultFileList.md correctly 1`] = ` `; +exports[`renders ./components/upload/demo/directory.md correctly 1`] = ` + +
+
+ +`; + exports[`renders ./components/upload/demo/drag.md correctly 1`] = ` + + +, mountNode); +```` diff --git a/components/upload/demo/picture-style.md b/components/upload/demo/picture-style.md index e6a8c0d510..7aa53c301f 100644 --- a/components/upload/demo/picture-style.md +++ b/components/upload/demo/picture-style.md @@ -1,5 +1,5 @@ --- -order: 6 +order: 8 title: zh-CN: 图片列表样式 en-US: Pictures with list style diff --git a/components/upload/index.en-US.md b/components/upload/index.en-US.md index b79a1bdf58..0f6b41b91f 100644 --- a/components/upload/index.en-US.md +++ b/components/upload/index.en-US.md @@ -21,7 +21,8 @@ Uploading is the process of publishing information (web pages, text, pictures, v | Property | Description | Type | Default | | -------- | ----------- | ---- | ------- | | accept | File types that can be accepted. See [input accept Attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-accept) | string | - | -| action | Required. Uploading URL | string | - | +| action | Required. Uploading URL | string\|(file) => `Promise` | - | +| directory | support upload whole directory ([caniuse](https://caniuse.com/#feat=input-file-directory)) | boolean | fasle | | beforeUpload | Hook function which will be executed before uploading. Uploading will be stopped with `false` or a rejected Promise returned. **Warning:this function is not supported in IE9**。 | (file, fileList) => `boolean | Promise` | - | | customRequest | override for the default xhr behavior allowing for additional customization and ability to implement your own XMLHttpRequest | Function | - | | data | Uploading params or function which can return uploading params. | object\|function(file) | - | @@ -61,7 +62,7 @@ When uploading state change, it returns: name: 'xx.png' // file name status: 'done', // options:uploading, done, error, removed response: '{"status": "success"}', // response from server - linkProps: '{"download": "image"}', // additional html props of file link + linkProps: '{"download": "image"}', // additional html props of file link } ``` diff --git a/components/upload/index.zh-CN.md b/components/upload/index.zh-CN.md index 814a5f4118..e7e07ed2e7 100644 --- a/components/upload/index.zh-CN.md +++ b/components/upload/index.zh-CN.md @@ -22,10 +22,11 @@ title: Upload | 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | accept | 接受上传的文件类型, 详见 [input accept Attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-accept) | string | 无 | -| action | 必选参数, 上传的地址 | string | 无 | +| action | 必选参数, 上传的地址 | string\|(file) => `Promise` | 无 | +| directory | 支持上传文件夹([caniuse](https://caniuse.com/#feat=input-file-directory))| boolean | fasle | | beforeUpload | 上传文件之前的钩子,参数为上传的文件,若返回 `false` 则停止上传。支持返回一个 Promise 对象,Promise 对象 reject 时则停止上传,resolve 时开始上传。**注意:IE9 不支持该方法**。 | (file, fileList) => `boolean | Promise` | 无 | | customRequest | 通过覆盖默认的上传行为,可以自定义自己的上传实现 | Function | 无 | -| data | 上传所需参数或返回上传参数的方法 | object\|function(file) | 无 | +| data | 上传所需参数或返回上传参数的方法 | object\|(file) => object | 无 | | defaultFileList | 默认已经上传的文件列表 | object\[] | 无 | | disabled | 是否禁用 | boolean | false | | fileList | 已经上传的文件列表(受控),使用此参数时,如果遇到 `onChange` 只调用一次的问题,请参考 [#2423](https://github.com/ant-design/ant-design/issues/2423) | object\[] | 无 | diff --git a/components/upload/interface.tsx b/components/upload/interface.tsx index 64370c5b44..0c265ba60b 100755 --- a/components/upload/interface.tsx +++ b/components/upload/interface.tsx @@ -55,7 +55,8 @@ export interface UploadProps { name?: string; defaultFileList?: Array; fileList?: Array; - action?: string; + action?: string | ((file: UploadFile) => PromiseLike); + directory?: boolean; data?: Object | ((file: UploadFile) => any); headers?: HttpRequestHeader; showUploadList?: boolean | ShowUploadListInterface; diff --git a/package.json b/package.json index 7e6f862a15..1f65c4630c 100644 --- a/package.json +++ b/package.json @@ -77,7 +77,7 @@ "rc-tooltip": "~3.7.0", "rc-tree": "~1.12.0", "rc-tree-select": "~1.12.0", - "rc-upload": "~2.4.0", + "rc-upload": "~2.5.0", "rc-util": "^4.0.4", "react-lazy-load": "^3.0.12", "react-slick": "~0.23.1",