# cdn2

> Upload your files to cdn.

Latest version **0.0.3** (published 2016-09-19) · MIT license · 0 weekly downloads

## Install

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

Provides the command `cdn2`.

## 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.0.3 |
| Published | 2016-09-19 |
| First published | 2016-09-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.10.0 |
| Dependencies | 11 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | yes |
| GitHub stars | 16 |
| Author | afc163 |
| Maintainers | jso0 |
| Keywords | cdn, upload, qiniu, upyun |

## Links

- npm: https://www.npmjs.com/package/cdn2
- Repository: https://github.com/afc163/cdn
- Homepage: https://github.com/afc163/cdn#readme
- Issues: https://github.com/afc163/cdn/issues
- npm.io page: https://npm.io/package/cdn2

## Dependencies (11)

- [async](https://npm.io/package/async.md) ^0.9.0
- [upyun](https://npm.io/package/upyun.md) 0.0.3
- [shelljs](https://npm.io/package/shelljs.md) ^0.3.0
- [cliparoo](https://npm.io/package/cliparoo.md) ^1.0.0
- [colorful](https://npm.io/package/colorful.md) ^2.1.0
- [download](https://npm.io/package/download.md) ^0.1.18
- [tempfile](https://npm.io/package/tempfile.md) ^0.1.3
- [commander](https://npm.io/package/commander.md) ~2.2.0
- [imageinfo](https://npm.io/package/imageinfo.md) ^1.0.4
- [uglify-js](https://npm.io/package/uglify-js.md) ^2.4.14
- [node-qiniu](https://npm.io/package/node-qiniu.md) ^6.1.6

## Recent versions

- 0.0.3 (latest) — 2016-09-19
- 0.0.2 — 2016-09-19
- 0.0.1 — 2016-09-19

## README

# CDN

[![NPM version](https://img.shields.io/npm/v/cdn.svg?style=flat)](https://npmjs.org/package/cdn)

上传静态文件到七牛或又拍云服务器上，生成随机的地址返回。目前支持 .png .jpg .jpeg .gif .ico .swf .js .css .zip .pdf .flv .mp4 这些类型的文件。

![demo](http://cdn-qiniu.qiniudn.com/0e751d59490edeb21fe27344f2cde425.png)

---

## 安装

```
$ npm install cdn -g
```

## 配置

```
$ vi ~/.cdn_config
```

编辑此文件，你可以修改默认上传源，以及配置自己的上传空间。

## 使用

```
$ cdn test.jpg
```

```
Start checking files.
Ready to upload one file:
  spmjs.png @ image/png 7.54 KB 400x400
Busy in uploading ☕  ...
  ➜  http://cdn-qiniu.qiniudn.com/650bb27d284b3c70ed732d0b4629a0a1.png ~ spmjs.png
👍  Uploaded one file to QINIU in 0.267s!
```

就可以访问 http://cdn-qiniu.qiniudn.com/650bb27d284b3c70ed732d0b4629a0a1.png 了。

上传成功后 cdn 地址将会自动复制到剪贴板中。

### 多文件部署

支持多文件上传和通配符的匹配。

```
$ cdn test1.js test2.js test3.css
```

```
$ cdn *.jpg
```

### 部署网络地址

```
$ cdn https://www.npmjs.org/static/img/npm.png
```

### 相对绝对路径

```
$ cdn ../../test.jpg
```

```
$ cdn /home/admin/test.jpg
```

### 在 NodeJS 中

```js
var cdn = require('cdn');

cdn('/path/to/test.jpg', function(err, url) {
    // url -> http://cdn-qiniu.qiniudn.com/650bb27d284b3c70ed732d0b4629a0a1.png
});
```

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