@blinkmobile/aws-s3
our simplified wrapper for common AWS S3 operations
Last updated 7 months ago by blinkmobile-admin .
BSD-3-Clause · Repository · Bugs · Original npm · Tarball
$ cnpm install @blinkmobile/aws-s3 
SYNC missed versions from official npm registry.

blinkmobile/aws-s3 npm module Build Status Greenkeeper badge AppVeyor Status

our simplified wrapper for common AWS S3 operations

Getting Started

npm install @blinkmobile/aws-s3 aws-sdk
const upload = require('@blinkmobile/aws-s3').upload;
const AWS = require('aws-sdk');

Requirements

AWS SDK for Javascript, version >= v2.3.9

Usage

const task = upload({
  // common options
  cwd: '', // current working directory to search, defaults to `process.cwd()`
  prune: false, // true => delete S3 Objects that don't match local files
  s3: new AWS.S3({ /* ... */ }),

  // advanced options
  dryRun: false, // true bypasses write calls with simulated success events
  filePaths: [''], // paths relative to rootPath, defaults to glob(['**/*'])
  fs: null, // defaults to `require('fs')`
  bucketPathPrefix: '' // upload objects to base path in S3 bucket
});

const EventEmitter = require('events');
console.assert(task instanceof EventEmitter);
console.assert(task.promise instanceof Promise);

.blinkmignore

We ignore certain files and directories by default.

The "cwd" directory may also contain a ".blinkmignore" file. This file is like a .gitignore file.

This file should contain globs, which we combine with the above defaults for the "ignore" option for glob.

Example:

# we ignore comments and empty lines

do-not-upload/**/anything-in-this-directory/**/*
or-this-file.txt

API

upload (options: UploadOptions) => Task
interface Task extends EventEmitter {
  filePaths: String[],
  files: Map,
  objects: Map,
  promise: Promise
}

Note: until task.promise resolves / rejects, other properties may not be available. EventEmitter methods are always available.

interface UploadOptions {
  cwd? : String, // defaults to process.cwd()
  dryRun = false: Boolean,
  filePaths?: String[], // defaults to glob(['**/*'])
  fs? : Object, // defaults to require('fs')
  prune = false : Boolean,
  s3: AWS.S3,
  skip = true : Boolean,
  bucketPathPrefix?: String // defaults to ''
}

Events

  • skipped: fileName

  • uploading: fileName

  • uploaded: fileName

  • error: error, fileName

  • deleting: fileName

  • deleted: fileName

const task = upload({ /* ... */ });
task.on('error', (error, fileName) => {
  // TODO: ...
});

Roadmap

  • [ ] "dryRun" option
  • [ ] "fs" option
Downloads
Today 0
This Week 8
This Month 16
Last Day 0
Last Week 8
Last Month 17
Dependencies (9)
Dev Dependencies (11)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |