mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-21 13:18:04 +08:00
28 lines
742 B
TypeScript
28 lines
742 B
TypeScript
import React from 'react';
|
|
import { UploadOutlined } from '@ant-design/icons';
|
|
import type { UploadProps } from 'antd';
|
|
import { Button, Upload } from 'antd';
|
|
|
|
const props: UploadProps = {
|
|
action: '//jsonplaceholder.typicode.com/posts/',
|
|
listType: 'picture',
|
|
previewFile(file) {
|
|
console.log('Your upload file:', file);
|
|
// Your process logic. Here we just mock to the same file
|
|
return fetch('https://next.json-generator.com/api/json/get/4ytyBoLK8', {
|
|
method: 'POST',
|
|
body: file,
|
|
})
|
|
.then((res) => res.json())
|
|
.then(({ thumbnail }) => thumbnail);
|
|
},
|
|
};
|
|
|
|
const App: React.FC = () => (
|
|
<Upload {...props}>
|
|
<Button icon={<UploadOutlined />}>Upload</Button>
|
|
</Upload>
|
|
);
|
|
|
|
export default App;
|