JSPM

pkgcloud-image

0.1.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q38699F
  • License MIT

Image resize and upload by pkgcloud.

Package Exports

  • pkgcloud-image

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pkgcloud-image) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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.