npm.io
0.1.9 • Published 12 years ago

puush

Licence
MIT
Version
0.1.9
Deps
1
Vulns
2
Weekly
0

node-puush

Simple wrapper for puush.


  • Puush ([apiKey]) - Constructor, apiKey is optional.
  • auth (email, password [, callback]) - Authenticate user. API key saved on success.
  • auth_key (email, apikey [, callback]) - Same as auth(), using apikey instead of plain text password.
  • up (filename [, callback]) - Upload file. Maximum filesize for free account: 272629051 bytes
  • del (fileID [, callback]) - Remove uploaded file.
  • hist ([callback]) - List of previously uploaded files. Limited to 10 on server side.

Example

var Puush = require('puush');

var puush = new Puush();
// or, if you know your API Key already:
var puush = new Puush('YOURAPIKEY');

// callback function to show results
function showResult(err, result) {
  console.log(result)
};

puush.auth('your@email.net', 'SuperSecretPassword');
// or
puush.auth_key('your@email.net', 'YOURAPIKEY');

puush.up('yourfile.ext', showResult);
puush.hist(showResult); // limited to 10 on server side
puush.del(12345678, showResult);

Puush([apiKey])

Constructor, apiKey is optional.


auth(email, password [, callback])

Authenticate user. API key saved on success.

Result from callback:
{ premium: 0,           // account is premium (?)
  apiKey: 'YOURAPIKEY', // API key of the user
  expire: '',           // premium expiration date (?)
  sizeSum: 0 }          // sum of file sizes (?)
auth_key(email, apikey [, callback])

Same as auth(), using apikey instead of plain text password.


up(filename [, callback])

Upload a file.
Maximum file size for free account: 260MB-708B-filename.length,
if your filename is only 1 character, then it is: 272629051 bytes

Result from callback:
{ id: 123465,                // uploaded file id
  url: 'http://puu.sh/x/y' } // download url
del(fileID [, callback])

Remove uploaded file. Result is the same as hist().

hist([callback])

List of previously uploaded files. Limited to 10 on server side.

Result from callback:
[ { id: 123456,               // uploaded file id
    datetime: 'Wed Jan 01 2014 00:00:00 GMT', // upload datetime
    url: 'http://puu.sh/x/y', // download url
    filename: 'yourfile.txt', // name of the uploaded file
    views: 1 },               // number of views
  { // more files...
  }
]

##Notes

  • If you include your API key in the constructor, you dont have to auth.
  • Question marked properties at callback results are wild guesses.

##Todo

  • Constructor ([email, password]|[apiKey])
  • Implement thumb
  • raw property at result, for unparsed response

Keywords