0.02
No commit activity in last 3 years
No release in over 3 years
FilePreviews.io Ruby library and CLI application.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0

Runtime

~> 0.17.3
~> 1.3.0
 Project Readme

FilePreviews.io (Ruby client)

Gem Version Build Status Maintainability Inline docs

Ruby client library and CLI tool for the FilePreviews.io service. Generate image previews and metadata from almost any kind of file.

Installation

Add this line to your application's Gemfile:

gem 'filepreviews'

Or via GitHub Package Manager:

gem 'filepreviews', source: 'https://rubygems.pkg.github.com/jonahoffline'

And then execute:

$ bundle

Or install it yourself as:

$ gem install filepreviews

Usage

Register your application for an API key at FilePreviews.io.

Configuration

To configure the gem to use your newly-registered api + secret keys, you can use one of the two configuration styles:

Block style:

require 'filepreviews'

Filepreviews.configure do |config|
  config.api_key = 'YOUR_API_KEY'
  config.secret_key = 'YOUR_SECRET_KEY'
end

Simpler style:

require 'filepreviews'

Filepreviews.api_key = 'YOUR_API_KEY'
Filepreviews.secret_key = 'YOUR_SECRET_KEY'

Basic Example Code

require 'filepreviews'

url = 'http://pixelhipsters.com/images/pixelhipster_cat.png'
result = Filepreviews.generate(url)

result.url
result.status
result.metadata # fetches metadata

Web Page Screencaptures

url = 'http://pixelhipsters.com'
result = Filepreviews.generate(url)

result.url
result.status
result.metadata

Options

You can optionally send an options object (per request).

conf = {
  options: {
    size: {
      width: 100,
      height: 999
    },
    # supported: 'exif', 'ocr', 'psd', 'checksum', 'multimedia',
    metadata: ['exif'],

    # supported: 'jpg', 'jpeg', 'png'
    format: 'jpg',

    # Arbitrary key/value pairs that are returned in the "user_data" field in response
    data: {
      uuid: 'database_identifier'
    },

    # Support for specifying custom headers when the preview is placed in storage container
    uploader: {
      destination: 'directory/name',
      headers: {} # common request headers to S3 bucket for instance
    },

    # supported: '1', '1-3', '1,3,5', '1-3', 'all'
    pages: '1-3',

    # Callback URL (POST) to send results
    callback_url: 'http://requestbin.fullcontact.com/1234'
  }
}

result = Filepreviews.generate(url, conf)
result.url
result.metadata

Command-Line Application

Options:

  • -k, --api_key [key] - use API key from Filepreviews.io
  • -s, --secret_key [key] - use secret key from Filepreviews.io
  • -m, --metadata - load metadata response
  • -v, --version - display the version
  • -h, --help - print help

Command-Line usage examples

Basic use

$ filepreviews http://www.pixelhipsters.com

With an API Key

$ filepreviews --api_key YOUR_API_KEY_HERE --secret_key YOUR_SECRET_KEY_HERE http://www.pixelhipsters.com

Autoload Full (metadata) Response

$ filepreviews -m http://pixelhipsters.com/images/pixelhipster_cat.png

Note: This will return a full metadata response, instead of the API's original response that only returns the url and status of the request.

Author

Discussion

If you have any questions, ideas or jokes:

Gitter chat

Contributing

Is it worth it? let me fork it

I put my thing down, flip it and debug it

Ti gubed dna ti pilf nwod gniht ym tup I

Ti gubed dna ti pilf nwod gniht ym tup I