# filefly

> All CDN upload in one SDK

Latest version **0.1.0** (published 2019-11-14) · 0 weekly downloads

## Install

```sh
npm install filefly
pnpm add filefly
yarn add filefly
bun add filefly
```

Provides the command `filefly`.

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2019-11-14 |
| First published | 2019-11-14 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 323 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | djyde |

## Links

- npm: https://www.npmjs.com/package/filefly
- npm.io page: https://npm.io/package/filefly

## Dependencies (4)

- [conf](https://npm.io/package/conf.md) ^6.2.0
- [open](https://npm.io/package/open.md) ^7.0.0
- [yargs](https://npm.io/package/yargs.md) ^14.2.0
- [ali-oss](https://npm.io/package/ali-oss.md) ^6.2.0

## Recent versions

- 0.1.0 (latest) — 2019-11-14

## README

# Filefly

All CDN/OSS upload providers in one command.

## Installation

```bash
# npm
npm i -g filefly

# yarn
yarn global add filefly
```

## Overview

```bash
# upload file to Aliyun OSS
filefly aliyun demo.jpg

# upload file to qiniu
filefly qiniu demo.jpg

# open config file
filefly config
```

## Config

Use `$ filefly config` to open the `config.json` folder:

```json
// config.json

{
	"aliyun": {
		"accessKeyId": "",
		"accessKeySecret": "",
		"customDomains": [
			"https://xxx.com",
		]
	}
}
```

## Programmatic usage

```bash
# npm
npm i filefly

# yarn
yarn add filefly
```

### Aliyun

#### interactive upload

```js
import { Aliyun } from 'filefly'

const aliyun = new Aliyun(process.env.ALIYUN_ID, process.env.ALIYUN_SECRET)

// You'll be asked for which Bucket to choose, what custom domain is, or custom upload bucket path
const { rawUrl, customUrl } = await aliyun.upload(path.resolve(__dirname, 'demo.jpg'))
```

#### directly upload

```js
const aliyun = new Aliyun(process.env.TEST_ALIYUN_ID, process.env.TEST_ALIYUN_SECRET, {
  // must set bucket name and region first
  bucketName: '',
  region: ''
})

const { rawUrl, customUrl } = await aliyun.uploadToBucket(path.resolve(__dirname, './demo.jpg'), {
  bucketPath: 'path/to',
  customDomain: 'https://assets.xxx.com'
})
```

## Roadmap

- [x] Aliyun
- [ ] qiniu
- [ ] AWS S3

# License

MIT License

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