Project

clientus

0.0
No commit activity in last 3 years
No release in over 3 years
A client for the Tus protocol enabling file uploads
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.0
 Project Readme

Clientus

The gem is dedicated to provide a simlpe and flexible way of uploading files via the Tus protocol.

Installation

Add this line to your application's Gemfile:

gem 'clientus'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install clientus

Usage

Case 1: Suppose you have an URL of the uploading interface

require 'clientus'

# simply create a client instance
client = Clientus::Client.new(url)

# then upload your file!
client.upload('foo/bar.txt')

# now bar.txt is somewhere on the server (or some exception appeared.. ouch!)

Case 2: You have some headers you want to pass along (ex.: session sid)

require 'clientus'

# describe your headers
# NOTE: tus-specific headers will be rewritten or adjusted
# ex.: if you defined Tus-Resumable header, its value will be replaced with one from the server
custom_headers = {
  'Cookie' => 'sid=09876543211234567890'
}

# pass your headers when creating a client instance
client = Clientus::Client.new(url, additional_headers: custom_headers)

# upload a file!
client.upload('foo/bar.txt')

Case 3: You want to use some custom http config (ex: you want to turn off the sertificate verification)

require 'clientus'

# describe a required http config
http_params = {
  use_ssl: true,
  verify_mode: OpenSSL::SSL::VERIFY_NONE
}

# pass your headers when creating a client instance
client = Clientus::Client.new(url, http_params: http_params)

# upload a file!
client.upload('foo/bar.txt')

Contributing

Bug reports and pull requests are welcome here!

License

The gem is available as open source under the terms of the MIT License.