0.0
Low commit activity in last 3 years
A long-lived project that still receives updates
tus server adapter for Paperclip
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 12.3.3
~> 3.0

Runtime

 Project Readme

paperclip-tus

Build Status

paperclip-tus is paperclip io adapter for tus-ruby-server.

Installation

Add this line to your application's Gemfile:

gem 'paperclip-tus'

And then execute:

$ bundle

Or install it yourself as:

$ gem install paperclip-tus

Usage

First, make sure you configure tus ruby server correctly. Only Tus::Storage::Filesystem storage is supported at the moment.

Then, you need tus-js-client. Set it up similar to this example. It's recommended to add metadata to tus.Upload options (to make sure names of uploaded files can be retrieved by the adapter):

var upload = new tus.Upload(file, {
      endpoint: ...,
      metadata: { filename: file.name },
      ...

Next, in onSuccess callback, you should extract file uid and submit it as has_attached_file attribute. Uid can be extracted from url:

var upload = new tus.Upload(file, {
  ...
  onSuccess: function() {
    var url_parts = upload.url.split('/')
    # get last part of url
    var uid = url_parts[url_parts.length - 1]
    ... [assign uid to attachment attribute]..
  }
  ...

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install:local.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/deees/paperclip-tus.

License

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