GithubHelp home page GithubHelp logo

shrinerb / shrine-tus Goto Github PK

View Code? Open in Web Editor NEW
10.0 6.0 1.0 54 KB

Plugin and storage for integrating Shrine and tus-ruby-server

Home Page: https://tus.io/

License: MIT License

Ruby 100.00%
shrine tus tus-ruby-server storage direct-upload

shrine-tus's People

Contributors

codingedward avatar janko avatar zdavis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

manifoldscholar

shrine-tus's Issues

Some Shrine plugins do not seem to run with shrine-tus

Given the following uploader, the determine_mime_type, and add_metadata plugins do not run. If I do not use the tus plugin, they work as expected. I couldn't find any documentation about this so I thought this to be a bug.

require 'tika/app'

class FileUploader < Shrine
  plugin :tus
  plugin :add_metadata
  plugin :moving

  plugin :determine_mime_type, analyzer: -> (io, analyzers) do
    Rails.logger.info '###########################################'
    Rails.logger.info 'determine_mime_type should be in the log'
    Rails.logger.info '###########################################'

    mime_type = analyzers[:file].call(io)
  	mime_type = analyzers[:mime_types].call(io) if mime_type == "text/plain"
  	mime_type
  end

  add_metadata :test do |io, context|
    Rails.logger.info '###########################################'
    Rails.logger.info 'add_metadata should be in the log'
    Rails.logger.info '###########################################'
    {}
  end
end

Remove or clarify dependency on tus-server

This plugin defines a dependency on tus-server (a Ruby implementation of a Tus server) in the gemspec. However, it never actually requires any files from that gem.

That said, it does implicitly depend on tus-server in this line:

rescue ::Tus::NotFound

That constant is defined in tus-server here.

Therefore, if I use shrine-tus without explicitly requiring tus-server, then I'll get a NameError if I hit an error in this method.

There are two potential solutions:

  1. Remove the dependency on tus-server. This would be my preference - I don't think shrine-tus as a Tus client should care about what server implementation is used. (On my project, we're using tusd, therefore we don't want/need the tus-server gem at all.)
  2. Require tus/errors so that the constant gets defined.

getting shrine-tus to run in a rails application

Dear @janko-m

Thank you for keeping this code open. I have integrated shrine with a Rails application, and it was a breeze, thanks. No such luck with shrine-tus. In particular it looks like I have trouble understanding the tus-server end. Would it be possible to get some more help?

I tired shrine-tus-demo, and it is not quite working for me either, but I would not pursue that much further, since it is not quite RoR anyway. I can see, however, that you have something called TusApp which is not mentioned anyplace else in tne code. How is TusApp supposed to work?

I can also see that in tus-ruby-server you are suggesting defining the endpoint location in config,ru. What should be the equivalent for TusApp? Where should /files directory be on the server? Would it be a bad idea to make it point to public/uploads/cache in the app?

Any help would be very much welcome.

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.