Skip to content

Instantly share code, notes, and snippets.

@shino
Created March 11, 2015 03:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shino/36f02377a687f8312631 to your computer and use it in GitHub Desktop.
Save shino/36f02377a687f8312631 to your computer and use it in GitHub Desktop.
'use strict';
var fs = require('fs'), AWS = require('aws-sdk');
AWS.config.update( { "accessKeyId": "1VXEJGY5YMQBIFJTDUY8",
"secretAccessKey": "XFOhEhcsuZYekrGHuby_5o7-gQJlb_Ue2e0GRA==",
"region": "us-east-1",
'httpOptions': {'proxy': 'http://127.0.0.1:15018'}});
AWS.config.update({region: ''});
var s3 = new AWS.S3();
var globalUnCaughtException = function(err) {
console.log("uncaughtException: ", err.stack);
};
process.on('uncaughtException', globalUnCaughtException);
function uploadFile(s3) {
console.log(s3);
var body = fs.createReadStream(fileName);
var params = {Bucket: bucket, Key: fileKey, Body: body};
s3.upload(params, function(err, data) {
console.log("uploaded", err, data);
});
};
if (process.argv[2] !== undefined ) {
// strip path for s3
var fileName = process.argv[2];
var fileKey = fileName.slice(fileName.lastIndexOf("/")+1);
console.log("fileKey: " + fileKey);
// S3 Upload options
var bucket = 'testje';
uploadFile(s3);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment