# @dyb881/file

> 文件处理工具，获取上传文件，文件转base64，base64转文件，图片裁剪压缩等

Latest version **0.2.3** (published 2020-11-20) · ISC license · 0 weekly downloads

## Install

```sh
npm install @dyb881/file
pnpm add @dyb881/file
yarn add @dyb881/file
bun add @dyb881/file
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.3 |
| Published | 2020-11-20 |
| First published | 2019-05-05 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 7.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | dyb881 |
| Maintainers | dyb881 |
| Keywords | file, tailoring |

## Links

- npm: https://www.npmjs.com/package/@dyb881/file
- Repository: https://github.com/dyb881/file
- Homepage: https://github.com/dyb881/file#readme
- Issues: https://github.com/dyb881/file/issues
- npm.io page: https://npm.io/package/@dyb881/file

## Dependencies (4)

- [react](https://npm.io/package/react.md) ^16.13.0
- [react-dom](https://npm.io/package/react-dom.md) ^16.13.0
- [@types/react](https://npm.io/package/@types/react.md) ^16.9.23
- [@types/react-dom](https://npm.io/package/@types/react-dom.md) ^16.9.5

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 0.2.3 (latest) — 2020-11-20
- 0.2.2 — 2020-09-24
- 0.2.1 — 2020-09-24
- 0.2.0 — 2020-09-24
- 0.1.9 — 2020-03-03
- 0.1.8 — 2020-03-03
- 0.1.7 — 2019-11-28
- 0.1.6 — 2019-11-28
- 0.1.5 — 2019-11-14
- 0.1.4 — 2019-06-17
- 0.1.3 — 2019-05-22
- 0.1.2 — 2019-05-07
- 0.1.1 — 2019-05-05

## README

# ！！已经停止更新，并迁移到 [Seasoning](https://dyb881.github.io/seasoning/common/tools/file-tool)

# file

文件处理工具，获取上传文件，文件转 base64，base64 转文件

## 获取上传文件

无需创建 input[type="file"] 标签，直接函数异步获取上传文件

```
import { getFile } from '@dyb881/file';

getFile().then(files => {
  files // 上传文件列表 FileList(类数组)
});
```

## 获取图片对象 <img src="">/new Image()

传入 url 或 base64 字符串，返回图片对象

```
import { getImg } from '@dyb881/file';

getImg(url/base64).then(img => {
  img // 图片对象 <img src="">/new Image()
});
```

## 文件 & base64 互转

```
import { fileToBase64, base64ToFile } from '@dyb881/file';

fileToBase64(File).then(base64 => {
  base64
});
base64ToFile(base64).then(file => {
  file // 文件对象 new File()
})
```

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