Skip to content

七牛gulp插件,封装了上传,删除,预取,刷新等功能

License

Notifications You must be signed in to change notification settings

justb/gulp-qiniu-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

七牛云存储

gulp-qiniu-utils, such as upload, remove, prefetch, refresh and so on

七牛gulp插件,封装了上传,删除,预取,刷新等功能

Install:

Install with npm or cnpm

npm install --save-dev gulp-qiniu-utils
cnpm install --save-dev gulp-qiniu-utils

Usage:

var gulp = require('gulp')
var Qiniu = require('gulp-qiniu-utils')

var qiniuOptions = {
  ak: 'your accessKey',
  sk: 'your secretKey',
  zone: 'Zone_z2',//空间对应存储区域(华东:z0,华北:z1,华南:z2,北美:na0)
  bucket: '...',//七牛对应空间
  upload: {
    dir: './public/dist',//上传本地目录
    prefix: 'test/',//上传时添加的前缀,可省略
    except: /\.(html|js)$/ //上传时不上传文件的正则匹配
  },
  remote: {
    url: 'http...',//七牛空间域名
    prefix: {
      default: 'test/',//七牛空间默认前缀,如果下面三个相同可省略
      remove: 'test/',//七牛空间删除前缀
      prefetch: 'test/',//七牛空间预取前缀
      refresh: 'test/'//七牛空间刷新前缀
    }
  }
}

gulp.task('upload', function (cb) {
  var qiniu = new Qiniu(qiniuOptions)
  qiniu.remove()
    .then(r => qiniu.upload().then(files=>console.log(files))) //根据自己的需求来调用相应的方法
    .then(r => qiniu.refresh())
    .then(r => qiniu.prefetch())
    .then(r => cb())
})

PS:有什么问题或者建议可以在github上面提,觉得好用的话可以点个star

About

七牛gulp插件,封装了上传,删除,预取,刷新等功能

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published