# xy-upload

> 基于 React Hooks 的上传组件

Latest version **0.3.1** (published 2020-06-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install xy-upload
pnpm add xy-upload
yarn add xy-upload
bun add xy-upload
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2020-06-05 |
| First published | 2019-06-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 8 |
| Unpacked size | 82.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | XueYou |
| Maintainers | xueyou2000 |
| Keywords | react, react-component, xy-upload |

## Links

- npm: https://www.npmjs.com/package/xy-upload
- Repository: https://github.com/xueyou2000/xy-upload
- Homepage: https://github.com/xueyou2000/xy-upload#readme
- Issues: https://github.com/xueyou2000/xy-upload/issues
- npm.io page: https://npm.io/package/xy-upload

## Dependencies (8)

- [react](https://npm.io/package/react.md) ^16.12.0
- [tslib](https://npm.io/package/tslib.md) ^1.10.0
- [react-dom](https://npm.io/package/react-dom.md) ^16.12.0
- [classnames](https://npm.io/package/classnames.md) ^2.2.6
- [utils-hooks](https://npm.io/package/utils-hooks.md) ^0.0.71
- [@fortawesome/react-fontawesome](https://npm.io/package/@fortawesome/react-fontawesome.md) ^0.1.4
- [@fortawesome/fontawesome-svg-core](https://npm.io/package/@fortawesome/fontawesome-svg-core.md) ^1.2.22
- [@fortawesome/free-solid-svg-icons](https://npm.io/package/@fortawesome/free-solid-svg-icons.md) ^5.10.2

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.3.1 (latest) — 2020-06-05
- 0.2.0 — 2019-12-30
- 0.1.0 — 2019-11-19
- 0.0.57 — 2019-11-05
- 0.0.56 — 2019-11-01
- 0.0.55 — 2019-11-01
- 0.0.54 — 2019-09-20
- 0.0.53 — 2019-09-18
- 0.0.52 — 2019-09-11
- 0.0.51 — 2019-09-09
- 0.0.5 — 2019-09-09
- 0.0.41 — 2019-09-07
- 0.0.4 — 2019-09-07
- 0.0.3 — 2019-09-06
- 0.0.2 — 2019-09-03
- … 1 more at https://npm.io/package/xy-upload/versions

## README

| ![IE](https://github.com/alrra/browser-logos/blob/master/src/edge/edge_48x48.png?raw=true) | ![Chrome](https://github.com/alrra/browser-logos/blob/master/src/chrome/chrome_48x48.png?raw=true) | ![Firefox](https://github.com/alrra/browser-logos/blob/master/src/firefox/firefox_48x48.png?raw=true) | ![Opera](https://github.com/alrra/browser-logos/blob/master/src/opera/opera_48x48.png?raw=true) | ![Safari](https://github.com/alrra/browser-logos/blob/master/src/safari/safari_48x48.png?raw=true) |
| ------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| IE 10+ ✔                                                                                   | Chrome 31.0+ ✔                                                                                     | Firefox 31.0+ ✔                                                                                       | Opera 30.0+ ✔                                                                                   | Safari 7.0+ ✔                                                                                      |

![NPM version](http://img.shields.io/npm/v/xy-upload.svg?style=flat-square)
![node version](https://img.shields.io/badge/node.js-%3E=_0.10-green.svg?style=flat-square)
![npm download](https://img.shields.io/npm/dm/xy-upload.svg?style=flat-square)

[![xy-upload](https://nodei.co/npm/xy-upload.png)](https://npmjs.org/package/xy-upload)

# xy-upload

上传组件

## 安装

```bash
# yarn
yarn add xy-upload
```

## 使用例子

```tsx
import React from "react";
import ReactDOM from "react-dom";
import { Upload } from "xy-upload";
ReactDOM.render(
    <Upload action="/upload.do">
        <button>上传</button>
    </Upload>,
    container,
);
```

## API

| 属性            | 说明                                                    | 类型                                                               | 默认值  |
| --------------- | ------------------------------------------------------- | ------------------------------------------------------------------ | ------- |
| disabled        | 是否禁用                                                | boolean                                                            | `false` |
| accept          | 上传文件类型                                            | string                                                             | -       |
| multiple        | 是否多选                                                | boolean                                                            | `false` |
| beforeUpload    | 上传前检查, 返回 false 或者 Promise.reject() 则拒绝上传 | BeforeUploadFunc, BeforeUploadPromise                              | -       |
| directory       | 是否支持上传目录内所有文件(不支持 IE)                   | boolean                                                            | `false` |
| customRequest   | 自定义上传                                              | (options: UploadOptions) => UploadReturn                           | -       |
| name            | 服务器接受文件名称                                      | string                                                             | `file`  |
| action          | 上传地址                                                | string, Function                                                   | -       |
| data            | 附加数据                                                | object, Function                                                   | -       |
| withCredentials | 是否启用 withCredentials                                | boolean                                                            | `false` |
| headers         | 附加请求头                                              | object                                                             | -       |
| onStart         | 开始上传                                                | (file: FileExtend) => void                                         | -       |
| onSuccess       | 成功事件                                                | (file: FileExtend, response: ResType, xhr: XMLHttpRequest) => void | -       |
| onError         | 失败事件                                                | (file: FileExtend, error: Error, response?: ResType) => void       | -       |
| onProgress      | 上传进度事件                                            | (file: FileExtend, percent: number, event: ProgressEvent) => void  | -       |

## 开发

```sh
yarn run start
```

## 例子

http://localhost:6006

## 测试

```
yarn run test
```

## 开源许可

xy-upload is released under the MIT license.

---
_Source: https://npm.io/package/xy-upload · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
