filepicker
v0.2.0
Published
Server-side file storage using Filepicker.io
Downloads
138
Readme
Filepicker Server-side Library
The fantastic folks at Filepicker.io have a service that allows for easy storage of files, primarily on the client-side. There may, however, be instances in which you want to put photos from the server-side into your Filepicker bucket.
That's where this library comes in. Modified from the client library maintained by the Filepicker staff, this server-side library simply makes RESTy requests.
Installation
Through NPM
$ npm install filepicker
or using Git
$ git clone git://github.com/filepicker/cellar.git node_modules/filepicker/
API/How to Use
This library only implements one of the methods from the client library (getUrlFromData) as well as two methods more suited to a Node environment
Instantiation
var Filepicker = require('filepicker');
var filepicker = new Filepicker('YOUR_API_KEY');
Methods
getUrlFromData
- A direct translation from the client library, stores contents of a file
filepicker.getUrlFromData("some text to store", {persist:true}, function(err, url) { console.log("my file is stored at "+url); });
getUrlFromUrl
- Makes a request to the specified location, and stores the data found there on Filepicker
filepicker.getUrlFromUrl('http://example.com/mypic.jpg', {persist:true}, function(err, url) { console.log("the picture at http://example.com/mypic.jpg is now stored at "+url); });
getUrlFromBuffer
- Stores a Buffer on Filepicker
fs.readFile('/myfile.txt', function(err, buf) { filepicker.getUrlFromBuffer(buf, {persist:true}, function(err, url) { console.log("myfile.txt is now stored at "+url); }); })