Giter VIP home page Giter VIP logo

cdn's Introduction

CDN

NPM version

上传静态文件到七牛或又拍云服务器上,生成随机的地址返回。目前支持 .png .jpg .jpeg .gif .ico .swf .js .css .zip .pdf .flv .mp4 这些类型的文件。

demo


安装

$ 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 中

var cdn = require('cdn');

cdn('/path/to/test.jpg', function(err, url) {
    // url -> http://cdn-qiniu.qiniudn.com/650bb27d284b3c70ed732d0b4629a0a1.png
});

cdn's People

Contributors

afc163 avatar hotoo avatar renovate-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cdn's Issues

装了之后,bash里找不到这个命令啊

Last login: Thu Jun 2 11:35:47 on ttys005
kaiweixkw:~ xiekaiwei$ npm install cdn -g
npm WARN deprecated [email protected]: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
kaiweixkw:~ xiekaiwei$ cdn
-bash: cdn: command not found
kaiweixkw:~ xiekaiwei$ ls
Ali JailBreak Swift
AliDrive Learn! UI
AndroidStudioProjects Library Workspace
Applications Movies apache-maven-3.2.1
Books Music bin
Desktop Org node_hsf_config_snapshots
Documents Pictures sofa
Downloads Public
Github Spare
kaiweixkw:~ xiekaiwei$ cdn
-bash: cdn: command not found
kaiweixkw:~ xiekaiwei$ vi /.cdn_config
kaiweixkw:
xiekaiwei$ cdn
-bash: cdn: command not found
kaiweixkw:~ xiekaiwei$

Install error

/usr/local/bin/cdn -> /usr/local/lib/node_modules/cdn/bin/cdn

> [email protected] postinstall /usr/local/lib/node_modules/cdn
> node scripts/postinstall.js


fs.js:438
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^
Error: EACCES, permission denied '<HOME>/.cdn_config'
    at Object.fs.openSync (fs.js:438:18)
    at Object.fs.writeFileSync (fs.js:977:15)
    at Object.<anonymous> (/usr/local/lib/node_modules/cdn/lib/config.js:25:6)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/cdn/scripts/postinstall.js:1:63)
npm ERR! [email protected] postinstall: `node scripts/postinstall.js`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is most likely a problem with the cdn package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node scripts/postinstall.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls cdn
npm ERR! There is likely additional logging output above.

node -v v0.10.31
npm -v 1.4.4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.