Skip to content

egg-/pkgcloud-image

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pkgcloud-image

version download

Image resize and upload by pkgcloud.

js-standard-style

Dependencies

Usage

var AWS = require('aws-sdk')
var Image = require('../')
var config = require('./config.json')

var credentials = new AWS.SharedIniFileCredentials({ profile: config.profile })
var image = new Image({
  provider: 'amazon',
  key: credentials.secretAccessKey,
  keyId: credentials.accessKeyId,
  region: config.s3.region,
  container: config.s3.bucket,
  cdn: config.s3.cdn
})

var file = {
  path: 'img.jpg',
  extension: 'jpg',
  mimetype: 'image/jpg'
}

var thumbs = [
  {
    base: 'test',
    prefix: '100x100',
    size: [100, 100]
  }
]

image.uploads({
  file: file,
  thumbs: thumbs
}, function (err, result) {
  console.log(err, result)
  image.delete([
    result[0].replace(config.s3.cdn, '')
  ], function (err) {
    console.log(err)
  })
})
// config.json
{
    "profile": "s3.profile name",
    "s3": {
        "bucket": "bucketname",
        "region": "ap-northeast-1",
        "cdn": "https://cdnsubdomain.cloudfront.net/"
    }
}

Release History

See the changelog

LICENSE

pkgcloud-image is licensed under the MIT license.

About

Image resize and upload by pkgcloud

Resources

License

Stars

Watchers

Forks

Packages

No packages published