shrinerb / shrine-tus Goto Github PK
View Code? Open in Web Editor NEWPlugin and storage for integrating Shrine and tus-ruby-server
Home Page: https://tus.io/
License: MIT License
Plugin and storage for integrating Shrine and tus-ruby-server
Home Page: https://tus.io/
License: MIT License
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.
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
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:
shrine-tus/lib/shrine/storage/tus.rb
Line 20 in d586ee0
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:
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.)tus/errors
so that the constant gets defined.A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.