0.3.4 • Published 7 years ago
cdn-uploader v0.3.4
cdn-uploader
Upload files to one or more CDN through FTP, it is also a gulp plugin.
Usage
var gulp = require('gulp')
var cdnUploader = require('cdn-uploader')
var CDNs = [{
slot: 'upyun',
api_host: 'v0.api.upyun.com',
operator: 'operator',
bucket: 'bucket',
password: process.env.CDN_PWD
}, {
host: 'ftp.keycdn.com'
user: 'username'
password: process.env.CDN_PWD
}]
gulp.task('cdn', function () {
return gulp.src('dist/static/**')
.pipe(cdnUploader('/static', CDNs))
})
export your ftp password to shell:
export CDN_PWD='ftppassword'
API
var cdnUploader = require('cdn-uploader')
cdnUploader(remoteFolder, cdnList, options)
remoteFolder
: {String}, FTP foldercdnList
: {Array}, one or more CDN options, could be FTP options or plugin specific optionsoptions
: {Object}, options of cdn-uploader, keys include:cache
: Cached file list path, setfalse
to disable cache mechanism, default to.cdnUploaderCache
Return a through stream.
Plugins
You can set slot
in CDN options to enable the corresponding plugins.
FTP plugin is used as default plugin when slot
is not set or not valid.
UPYUN
UPYUN plugin use the UPYUN HTTP REST API to upload files.
You should set slot: upyun
in CDN options to enable this plugin.
Besides, field api_host
, operator
, bucket
and password
are also required.
License
MIT © Teambition