Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bin/pushfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ opts
.usage('[options] <file ...>')
.option('-u, --unique', 'Gives a unique hash for uploaded file.')
.option('-c, --configure', 'Create a configuration file.')
.option('-p, --private', 'Makes the file, when pushed, private.')
.option('-v, --version', 'Prints Version');

opts
Expand All @@ -20,6 +21,7 @@ opts
console.log(' $ pushfile <FILENAME>');
console.log(' $ pushfile -v');
console.log(' $ pushfile -c');
console.log(' $ pushfile -p');
console.log('');
});

Expand All @@ -31,7 +33,7 @@ if (opts.configure) {
pushfile.createConfig();
}
else if (optsLength > 0) {
pushfile.pushfile(opts.args[0], unique=opts.unique);
pushfile.pushfile(opts.args[0], unique=opts.unique, privateACL=opts.private);
}
else if (optsLength <= 0) {
console.log("no filename...")
Expand Down
8 changes: 6 additions & 2 deletions lib/pushfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de

let hashfile = require('./hashfile');

function pushfile(filename, unique) {
function pushfile(filename, unique, privateACL) {
let s3Bucket;
let config;
try {
Expand All @@ -58,10 +58,14 @@ function pushfile(filename, unique) {
}
hashfile.hash(filename, salt, newFilename => {
let contentType = _mime2.default.lookup(filename);
let fileACL = 'public-read';
if (privateACL) {
fileACL = 'private';
}
_fs2.default.readFile(filename, (err, fileBuffer) => {
const params = {
Key: newFilename,
ACL: 'public-read',
ACL: fileACL,
Body: fileBuffer,
ContentType: contentType
};
Expand Down
8 changes: 6 additions & 2 deletions src/pushfile.es6
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import mime from 'mime';

let hashfile = require('./hashfile');

export function pushfile(filename, unique) {
export function pushfile(filename, unique, privateACL) {
let s3Bucket;
let config;
try {
Expand All @@ -31,10 +31,14 @@ export function pushfile(filename, unique) {
}
hashfile.hash(filename, salt, newFilename => {
let contentType = mime.lookup(filename);
let fileACL = 'public-read'
if (privateACL) {
fileACL = 'private';
}
fs.readFile(filename, (err, fileBuffer) => {
const params = {
Key: newFilename,
ACL: 'public-read',
ACL: fileACL,
Body: fileBuffer,
ContentType: contentType
};
Expand Down