Project

inky

0.0
No commit activity in last 3 years
No release in over 3 years
A ruby client for filepicker.io's REST API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
>= 1.0.0
~> 10.0
>= 3.2.0
>= 2.9.0
>= 1.20.0

Runtime

>= 2.2.0
>= 1.7.0
 Project Readme

Inky Inky Build Status Code Climate Test Coverage

A ruby client for filepicker.io. Built on top of the Filepicker REST API.

Installation

Add this to your Gemfile:

gem 'inky'

Basic Usage

To view information about an existing Filepicker file:

file = Inky::File.new('hFHUCB3iTxyMzseuWOgG')
file.uid
file.md5
file.mimetype
file.uploaded_at # converted to Time object
file.container
file.writeable
file.filename
file.location
file.key
file.path
file.size
file.url

file.metadata # hash of all available metadata

Storing files

First, authorize your Filepicker account. You must have a paid plan for cloud storage to work.

Inky.authorize! 'MyApiKey1234455665'

To upload a local file:

Inky::File.from_file(File.open('my_file.png')).save!

# this is equivalent to:
file = Inky::File.new
file.local_file = File.open('my_file.png')
file.save!

To save from a URL:

Inky::File.from_url('http://example.com/my_file.png').save!

# this is equivalent to:
file = Inky::File.new
file.remote_url = 'http://example.com/my_file.png'
file.save!

Configuration

file#save accepts several options:

file.save! location: 'S3', # Other options include 'azure', 'rackspace', 'dropbox'
           filename: 'my_cool_file.ogg',
           mimetype: 'application/ogg',
           path: '/my_cool_files/1234.png', # path to store on cloud storage
           container: 'myapp-development', # container/bucket on cloud storage
           access: 'public' # defaults to 'private'

Updating an existing file

file.save! can be used to update an existing file with new content from a local file or url:

file = Inky::File.new('hFHUCB3iTxyMzseuWOgG')
file.local_file = File.open('my_new_file.ogg')
file.save!

file = Inky::File.new('hFHUCB3iTxyMzseuWOgG')
file.remote_url = 'http://example.com/my_new_file.ogg'
file.save!

Contributing

  • Check the issue tracker. If nothing exists, add a new issue to track your contributions.
  • Fork the project and create a new branch for your bugfix.
  • Write your contribution.
  • Add tests, ensuring good code coverage.
  • Submit a pull request.

To add or update tests involving file uploads, you will need your own paid Filepicker account, and will need to add a .env file at the root of the project with the following line:

FILEPICKER_API_KEY: <YOUR_FILEPICKER_API_KEY>

Todo

  • Support security policies
  • Support basic/temporary FP uploads (without S3/cloud storage)