Code Monkey home page Code Monkey logo

filr's Introduction

Filr

Filr turns Flickr into a storage engine. Very useful now that everyone gets 1TB for free :)

Install

npm install filr-cli -g

This will put the filr bin in your path.

Authorization

First, create an app at http://www.flickr.com/services/apps/create/ and take note of your consumer keys.

# Add your keys
filr --auth CONSUMER_KEY CONSUMER_SECRET

Alternatively, manually create a .filr file in your $HOME folder, containing a json object with the consumer_key and consumer_secret keys:

// these are fake keys, obviously
{
    "consumer_key": "f0d87f09a8sd7f8a08f7a",
    "consumer_secret": "8f7dsa807fa98"
}

Complete the OAuth flow to obtain access tokens. Filr will attempt to open a browser for you, just enter the resulting PIN on the prompt that follows. Tokens are persisted to $HOME/.filr as token and token_secret.

Uploading

filr my_file1.txt my_file2.txt

Each file will be uploaded as a separate image. Resulting images are set to private so they won't show on your public photostream.

Encoding / decoding

The encode/decode functionality is exposed as

filr --encode radiohead.mp3 radio.png

filr --decode radio.png radiohead.mp3

How it works / caveats

Files are encoded as hex strings and saved as a tEXt chunk inside the PNG, so the actual image could be anything. Flickr preserves the original data intact in the "Original" size.

Unfortunately this method is very wasteful, resulting in file sizes 2-4x the original. PNG does support "zEXt" chunks which are compressed using zlib, but the libraries being used here don't. Even better (and more cool) would be to save data in the image itself as seen here.

There is probably a restriction on chunk sizes that will cause this to break on larger files, I have only tested up to 15mb.

Development

git clone gh:ricardobeat/filr.git
cd filr
npm install

Run cake watch (or npm run watch if you don't have coffeescript globally installed) to continuously build the coffee-script source.

To-do

  • upload folders
  • add images to separate set
  • match file icons by filetype?
  • custom base image
  • bitmap mode (save data as grayscale bitmap)

License

http://ricardo.mit-license.org

filr's People

Contributors

ricardobeat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

filr's Issues

upload failed

I got a problem when i post an file.png.


filr file.png

then i got:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML&>lt;HEAD&>lt;META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLEE>RROR: The requested URL could not be retrieved</TITLE>
<STYLE type="text/css"&>lt;!--BODY{background-color:#ffffff;font-family:verdana,sans-serif}PRE{font-family:sans-serif}--&>lt;/STYLE>
</HEAD&>lt;BODY>
<H1E>RROR</H1>
<H2T>he requested URL could not be retrieved</H2>
<HR noshade size="1px">
<P>
While trying to process the request:
<PRE>
POST /services/upload/?format=json HTTP/1.1
Content-Type: multipart/form-data; boundary=--------------------------287007216995492851233411
Host: api.flickr.com
Connection: keep-alive
Transfer-Encoding: chunked

</PRE>
<P>
The following error was encountered:
<UL>
<LI>
<STRONG>
Invalid Request
</STRONG>
</UL>

<P>
Some aspect of the HTTP Request is invalid.  Possible problems:
<UL>
<LI>Missing or unknown request method
<LI>Missing URL
<LI>Missing HTTP Identifier (HTTP/1.0)
<LI>Request is too large
<LI>Content-Length missing for POST or PUT requests
<LI>Illegal character in hostname; underscores are not allowed
</UL>
<PY>our cache administrator is <A HREF="mailto:91u830901"9>1u830901</A.> 

<BR clear="all">
<HR noshade size="1px">
<ADDRESS>
Generated Wed, 22 May 2013 13:35:14 GMT by cache.nd (squid/2.7.STABLE9-20110824)
</ADDRESS>
</BODY&>lt;/HTML>

Error uploading file.

My form:


{"_overheadLength":1708,"_valueLength":206,"_lengthRetrievers":[null],"writable":false,"readable":true,"dataSize":0,"maxDataSize":2097152,"pauseStreams":true,"_released":false,"_streams":["----------------------------287007216995492851233411\r\nContent-Disposition: form-data; name=\"api_key\"\r\n\r\n","57f017d1cbc099ba4cc1f43afa77ec46",null,"----------------------------287007216995492851233411\r\nContent-Disposition: form-data; name=\"description\"\r\n\r\n","7682 bytes",null,"----------------------------287007216995492851233411\r\nContent-Disposition: form-data; name=\"format\"\r\n\r\n","json",null,"----------------------------287007216995492851233411\r\nContent-Disposition: form-data; name=\"hidden\"\r\n\r\n","2",null,"----------------------------287007216995492851233411\r\nContent-Disposition: form-data; name=\"is_public\"\r\n\r\n","0",null,"----------------------------287007216995492851233411\r\nContent-Disposition: form-data; name=\"nojsoncallback\"\r\n\r\n","1",null,"----------------------------287007216995492851233411\r\nContent-Disposition: form-data; name=\"oauth_consumer_key\"\r\n\r\n","57f017d1cbc099ba4cc1f43afa77ec46",null,"----------------------------287007216995492851233411\r\nContent-Disposition: form-data; name=\"oauth_nonce\"\r\n\r\n","6BoXhMurXA7xbElQsOqjNE4nRYcM2oio",null,"----------------------------287007216995492851233411\r\nContent-Disposition: form-data; name=\"oauth_signature_method\"\r\n\r\n","HMAC-SHA1",null,"----------------------------287007216995492851233411\r\nContent-Disposition: form-data; name=\"oauth_timestamp\"\r\n\r\n","1369229911",null,"----------------------------287007216995492851233411\r\nContent-Disposition: form-data; name=\"oauth_token\"\r\n\r\n","72157633568672409-e9c011ecd7db7c1b",null,"----------------------------287007216995492851233411\r\nContent-Disposition: form-data; name=\"oauth_version\"\r\n\r\n","1.0A",null,"----------------------------287007216995492851233411\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n","file.png",null,"----------------------------287007216995492851233411\r\nContent-Disposition: form-data; name=\"oauth_signature\"\r\n\r\n","+LCu9XqWb62jR9MB77OxRMYdJ7s=",null,"----------------------------287007216995492851233411\r\nContent-Disposition: form-data; name=\"photo\"; filename=\"filr-hh0k4x5e.png\"\r\nContent-Type: image/png\r\n\r\n",{"source":{"_readableState":{"highWaterMark":65536,"buffer":[],"length":0,"pipes":null,"pipesCount":0,"flowing":false,"ended":false,"endEmitted":false,"reading":true,"calledRead":true,"sync":false,"needReadable":true,"emittedReadable":false,"objectMode":false,"ranOut":false,"awaitDrain":0,"readingMore":false,"decoder":null},"readable":true,"domain":null,"_events":{},"_maxListeners":10,"path":"/var/folders/wk/l11r28rs16jf6gdwf1kbwm2c0000gn/T/filr-hh0k4x5e.png","fd":null,"flags":"r","mode":438,"autoClose":true},"dataSize":0,"maxDataSize":null,"pauseStream":true,"_maxDataSizeExceeded":false,"_released":false,"_bufferedEvents":[{"0":"pause"},{"0":"pause"}],"_events":{}},null],"_currentStream":null,"_boundary":"--------------------------287007216995492851233411"}

and my "payload":


{ 
  host: 'api.flickr.com',
  path: '/services/upload/?format=json',
  headers: { 'content-type': 'multipart/form-data; boundary=--------------------------287007216995492851233411' },
  method: 'POST' 
}

so, Is anything wrong?

Can not add my keys

I use Mac OS and intalled filr using 'npm install filr-cli -g'. Now I ma trying to add keys but get the error:

$ filr --auth * **
Open http://www.flickr.com/services/oauth/authorize?oauth_token=***-
* in a browser

/usr/local/lib/node_modules/filr-cli/lib/flickr.js:32
return program.prompt("PIN: ", function(pin) {
^
TypeError: Object # has no method 'prompt'
at /usr/local/lib/node_modules/filr-cli/lib/flickr.js:32:22
at /usr/local/lib/node_modules/filr-cli/node_modules/OAuth/lib/oauth.js:538:7
at passBackControl (/usr/local/lib/node_modules/filr-cli/node_modules/OAuth/lib/oauth.js:379:11)
at IncomingMessage. (/usr/local/lib/node_modules/filr-cli/node_modules/OAuth/lib/oauth.js:398:9)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13)

How can I fix it ?
Thanks

Cannot make it works

I always meet the Cannot find module 'OAuth' error.
Googled but not help, here are what I tried:

  1. npm install oauth
  2. add oauth 0.9.10 to package.json and npm install -d
  3. redo npm install filr -g

Every time I run filr, the same error msg: Cannot find module 'OAuth'.
Please Help, and here are some console output:

........
npm info install [email protected]
npm info postinstall [email protected]
npm info prepublish [email protected]
[email protected] node_modules/should

[email protected] node_modules/oauth

[email protected] node_modules/rimraf
└── [email protected]

[email protected] node_modules/express
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
npm info ok
root@MyVPS2537:/usr/local/lib/node_modules/filr# fil
file filefrag filr
root@MyVPS2537:/usr/local/lib/node_modules/filr# fil
file filefrag filr
root@MyVPS2537:/usr/local/lib/node_modules/filr# filr

module.js:340
throw err;
^
Error: Cannot find module 'OAuth'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/usr/local/lib/node_modules/filr-cli/lib/flickr.js:14:11)
at Object. (/usr/local/lib/node_modules/filr-cli/lib/flickr.js:65:4)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)

auth does not work

Great hack.

Following the tutorial and typing

$ filr --auth mysecret myconsumer

only outputs

Please use filr --auth or edit /Users/advanced/.filr to add your API keys.

the file /Users/advanced/.filr does not exist and I don't know in which format I should create it

Node version requirement?

Got an error on install:
2148 error Error: git "clone" "git://github.com/chbrown/node-oauth.git" "C:\\npm-8828\\1369166927390-0.7526494257617742" failed with 128
2148 error at ChildProcess. (c:\Program Files\nodejs\node_modules\npm\lib\utils\exec.js:56:20)
2148 error at ChildProcess.EventEmitter.emit (events.js:99:17)
2148 error at Process._handle.onexit (child_process.js:678:10)
2153 error node -v v0.8.14
2154 error npm -v 1.1.65

Why not JPG ?

you could store meta data ( file name/s and type in the exif ) jpg essentially being a zip file anyway , also you could have a actual image of what the file represents, say a picture of the radiohead album or whatever :)

SSL is required

Just installed for first time, never had this working before. First test was to upload a jpg, but received an error saying 'SSL is required'.

$ filr candm.jpg 
Uploading candm.jpg...
<?xml version="1.0" encoding="utf-8" ?>
<rsp stat="fail">
    <err code="95" msg="SSL is required" />
</rsp>

Error uploading file.

Is this something I'm doing wrong on my end, did flickr change their interface, or is it something wrong with filr?

Thanks for the help,
J

Cannot find module 'OAuth'

I have a problem...;;;

like below

module.js:340
throw err;
^
Error: Cannot find module 'OAuth'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/usr/local/lib/node_modules/filr-cli/lib/flickr.js:14:11)
at Object. (/usr/local/lib/node_modules/filr-cli/lib/flickr.js:65:4)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)


a better url regex to get photo id

if (matches = url.match(/flickr\.com\/photos\/[^\/]+/(\d+)/)) {

This would be better than the current one

if (matches = url.match(/\w+\/(\d+)/)) {

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.