0.0.4 • Published 11 years ago

filepicker.js v0.0.4

Weekly downloads
2
License
-
Repository
github
Last release
11 years ago

filepicker-node

A Node.js Filepicker Library

Installation

$ npm install filepicker-node

Instantiation

var Filepicker = require('filepicker-node');
var filepicker = new Filepicker('YOUR_API_KEY');

Methods

  1. store

    • Stores a file into filepicker and passes the url in the response
    filepicker.store("test", {persist:true}, function(err, url) {
    	console.log(url);
    });
  2. read

    • Reads a file from filepicker and passes the contents in the callback
      • For now uses utf8
        filepicker.read(url, {}, function(err,data){
          console.log(data);
        });
  3. stream

    • Streams file buffer from filepicker
    		// Generated by CoffeeScript 1.6.3
    	/*
    	File Streaming Example
    	From Filepicker
    
    	Streaming is a NodeJS convention, its how it achieves
    	its extreme scalability.
    	*/
    	var Filepicker, Stream, file_url, filepicker, opts, writeStream;
    	Stream = require('stream');
    	Filepicker = require('../index');
    	filepicker = new Filepicker('YOUR_FILEPICKER_API_KEY');
    	writeStream = new Stream();
    	writeStream.writable = true;
    	writeStream.readable = true;
    
    	/*
    	Note pipe will send all data emited from filepicker.on 'data'
    	and send that buffered data to writeStream.write
    	*/
	writeStream.write = function(buffer) {
	  var formattedData;
	  formattedData = buffer.toString('utf8');
	  return console.log(formattedData);
	  /*
	  	From here we can take our formatted data
	  	and either emit it again
	  	writeStream.emit('data',formattedData)
	  
	  	Or we can do what ever we want with the data.
	  	OR we could even extend this example and add a
	  	callback to the params and send the data to a callback
	  	after its been formatted.
	  */

	};

	writeStream.end = function(buffer) {
	  writeStream.readable = false;
	  return writeStream.writable = false;
	};

	file_url = "YOUR_FILE_URL";
	opts = {};
	filepicker.stream(file_url, opts).pipe(writeStream);

```
0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago