Latest Threat Research:Malicious dYdX Packages Published to npm and PyPI After Maintainer Compromise.Details
Socket
Book a DemoInstallSign in
Socket

s3-component

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

s3-component

S3 client upload library

npmnpm
Version
0.4.0
Version published
Weekly downloads
6
500%
Maintainers
1
Weekly downloads
 
Created
Source

s3

S3 client upload library.

Installation

$ component install component/s3

Config

An S3 global must be initialized with some configuration:

  • policy - the base64 json policy
  • signature - the policy signature
  • bucket the bucket name
  • acl ACL such as "public-read"
  • key access key

Example

var Upload = require('s3');
var drop = require('drop-anywhere');

drop(function(err, drop){
  if ('upload' != drop.type) return;
  var file = drop.item.file;
  console.log('upload %s', file.name);
  var uid = Math.random() * 1e10 | 0;
  var upload = Upload(file, { name: uid })

  var prog = document.querySelector('#progress');
  upload.on('progress', function(e){
    prog.textContent = (e.percent | 0) + '%';
  });

  upload.end(function(err){
    if (err) throw err;
    console.log('upload complete %s', upload.name);
    console.log(upload.url);
  });
});

API

Upload(options)

  • name remote filename or file.name
  • type content-type or file.type

Events:

  • abort upload was aborted
  • progress upload in progress (e.percent etc)
  • end upload is complete

Testing

First populate ./config.json with your credentials:

{
  "key": "asdfasdfasdfasdf",
  "secret": "asdfasdfasdfasdfasdfadsfasfdsfdasdf+fHgg",
  "bucket": "files.example.com"
}

Boot the test server:

$ node test

License

MIT

Keywords

s3

FAQs

Package last updated on 20 Aug 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts