0.0
No commit activity in last 3 years
No release in over 3 years
Client for Ink File Picker
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.14.6
>= 0
~> 3.5.0

Runtime

~> 0.11.0
 Project Readme

InkFilePicker

Ruby API client for filestack.com. Previously known as Ink File Picker and filepicker.io.

Build Status

Installation

Add this line to your application's Gemfile:

gem 'ink_file_picker'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ink_file_picker

Usage

This client mirrors part of File Picker's JavaScript API.

Creating a client

# Create a client which will sign URLs. You may drop secret if you have
# not enabled this feature in your developer portal for your application.
client = InkFilePicker.client(key: 'you-api-key', secret: 'your-secret')

Storing a file

response = client.store_file file_or_path, content_type
response = client.store_url 'http://www.example.com/img.jpg'

Removing a file

response = client.remove url_or_handle_name

Read operations

url = client.convert_url url_or_handle_name, w: 100, h: 100
url = client.convert_url url_or_handle_name, {w: 100, h: 100}, expiry: (Time.now + 60 * 10).to_i

# Adds policy and signature, if secret given when client was created.
get_params = {} # Get params we'll be adding to the request.
url = client.retrieve_url url_or_handle_name
url = client.retrieve_url url_or_handle_name, get_params, expiry: (Time.now + 60 * 10).to_i


# Get simple stat on a file, like the Javascript client
stat = client.stat url_or_handle_name

dimentions = client.stat url_or_handle_name, {width: true, height: true}

Errors

When making requests to the API errors may occur. InkFilePicker::ClientError or InkFilePicker::ServerError will be raised if we are getting 4xx or 5xx responses back from File Picker. All errors inherits from InkFilePicker::Error.

We may also fail with a InkFilePicker::UnexpectedResponseError. This happens when for instance you ask File Picker to download a URL, but the server for the given URL fails to respond within five(?) seconds. We will then get a 200 OK, but the body will reveal the timeout error in text and the UnexpectedResponseError is raised. Other download errors may also be in the response, for instance "Invalid response when trying to read from http://some.url.com/here.jpg.

Contributing

  1. Fork it (https://github.com/Skalar/ink_file_picker/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request