Code Monkey home page Code Monkey logo

inky's Introduction

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)

inky's People

Contributors

smudge avatar

Watchers

 avatar Roberto Thais avatar James Cloos avatar  avatar

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.