mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 17:44:35 +08:00
upgrade rc-upload to 2.5
- support `directory` close #7315 - action can be a function return Promise
This commit is contained in:
parent
99d6e4c96c
commit
fd96967c87
@ -118,6 +118,20 @@ exports[`renders ./components/upload/demo/defaultFileList.md correctly 1`] = `
|
|||||||
</span>
|
</span>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`renders ./components/upload/demo/directory.md correctly 1`] = `
|
||||||
|
<span
|
||||||
|
class=""
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-upload ant-upload-select ant-upload-select-text"
|
||||||
|
style="display:"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
class="ant-upload-list ant-upload-list-text"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`renders ./components/upload/demo/drag.md correctly 1`] = `
|
exports[`renders ./components/upload/demo/drag.md correctly 1`] = `
|
||||||
<span
|
<span
|
||||||
class=""
|
class=""
|
||||||
|
26
components/upload/demo/directory.md
Normal file
26
components/upload/demo/directory.md
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
order: 6
|
||||||
|
title:
|
||||||
|
zh-CN: 文件夹上传
|
||||||
|
en-US: Upload directory
|
||||||
|
---
|
||||||
|
|
||||||
|
## zh-CN
|
||||||
|
|
||||||
|
支持上传一个文件夹里的所有文件。
|
||||||
|
|
||||||
|
## en-US
|
||||||
|
|
||||||
|
You can select and upload a whole directory.
|
||||||
|
|
||||||
|
````jsx
|
||||||
|
import { Upload, Button, Icon } from 'antd';
|
||||||
|
|
||||||
|
ReactDOM.render(
|
||||||
|
<Upload action="//jsonplaceholder.typicode.com/posts/" directory>
|
||||||
|
<Button>
|
||||||
|
<Icon type="upload" /> Upload Directory
|
||||||
|
</Button>
|
||||||
|
</Upload>
|
||||||
|
, mountNode);
|
||||||
|
````
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
order: 6
|
order: 8
|
||||||
title:
|
title:
|
||||||
zh-CN: 图片列表样式
|
zh-CN: 图片列表样式
|
||||||
en-US: Pictures with list style
|
en-US: Pictures with list style
|
||||||
|
@ -21,7 +21,8 @@ Uploading is the process of publishing information (web pages, text, pictures, v
|
|||||||
| Property | Description | Type | Default |
|
| 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 | - |
|
| 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` | - |
|
| 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 | - |
|
| 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) | - |
|
| 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
|
name: 'xx.png' // file name
|
||||||
status: 'done', // options:uploading, done, error, removed
|
status: 'done', // options:uploading, done, error, removed
|
||||||
response: '{"status": "success"}', // response from server
|
response: '{"status": "success"}', // response from server
|
||||||
linkProps: '{"download": "image"}', // additional html props of file link
|
linkProps: '{"download": "image"}', // additional html props of file link
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -22,10 +22,11 @@ title: Upload
|
|||||||
| 参数 | 说明 | 类型 | 默认值 |
|
| 参数 | 说明 | 类型 | 默认值 |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| accept | 接受上传的文件类型, 详见 [input accept Attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-accept) | string | 无 |
|
| 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` | 无 |
|
| beforeUpload | 上传文件之前的钩子,参数为上传的文件,若返回 `false` 则停止上传。支持返回一个 Promise 对象,Promise 对象 reject 时则停止上传,resolve 时开始上传。**注意:IE9 不支持该方法**。 | (file, fileList) => `boolean | Promise` | 无 |
|
||||||
| customRequest | 通过覆盖默认的上传行为,可以自定义自己的上传实现 | Function | 无 |
|
| customRequest | 通过覆盖默认的上传行为,可以自定义自己的上传实现 | Function | 无 |
|
||||||
| data | 上传所需参数或返回上传参数的方法 | object\|function(file) | 无 |
|
| data | 上传所需参数或返回上传参数的方法 | object\|(file) => object | 无 |
|
||||||
| defaultFileList | 默认已经上传的文件列表 | object\[] | 无 |
|
| defaultFileList | 默认已经上传的文件列表 | object\[] | 无 |
|
||||||
| disabled | 是否禁用 | boolean | false |
|
| disabled | 是否禁用 | boolean | false |
|
||||||
| fileList | 已经上传的文件列表(受控),使用此参数时,如果遇到 `onChange` 只调用一次的问题,请参考 [#2423](https://github.com/ant-design/ant-design/issues/2423) | object\[] | 无 |
|
| fileList | 已经上传的文件列表(受控),使用此参数时,如果遇到 `onChange` 只调用一次的问题,请参考 [#2423](https://github.com/ant-design/ant-design/issues/2423) | object\[] | 无 |
|
||||||
|
@ -55,7 +55,8 @@ export interface UploadProps {
|
|||||||
name?: string;
|
name?: string;
|
||||||
defaultFileList?: Array<UploadFile>;
|
defaultFileList?: Array<UploadFile>;
|
||||||
fileList?: Array<UploadFile>;
|
fileList?: Array<UploadFile>;
|
||||||
action?: string;
|
action?: string | ((file: UploadFile) => PromiseLike<any>);
|
||||||
|
directory?: boolean;
|
||||||
data?: Object | ((file: UploadFile) => any);
|
data?: Object | ((file: UploadFile) => any);
|
||||||
headers?: HttpRequestHeader;
|
headers?: HttpRequestHeader;
|
||||||
showUploadList?: boolean | ShowUploadListInterface;
|
showUploadList?: boolean | ShowUploadListInterface;
|
||||||
|
@ -77,7 +77,7 @@
|
|||||||
"rc-tooltip": "~3.7.0",
|
"rc-tooltip": "~3.7.0",
|
||||||
"rc-tree": "~1.12.0",
|
"rc-tree": "~1.12.0",
|
||||||
"rc-tree-select": "~1.12.0",
|
"rc-tree-select": "~1.12.0",
|
||||||
"rc-upload": "~2.4.0",
|
"rc-upload": "~2.5.0",
|
||||||
"rc-util": "^4.0.4",
|
"rc-util": "^4.0.4",
|
||||||
"react-lazy-load": "^3.0.12",
|
"react-lazy-load": "^3.0.12",
|
||||||
"react-slick": "~0.23.1",
|
"react-slick": "~0.23.1",
|
||||||
|
Loading…
Reference in New Issue
Block a user