Git Product home page Git Product logo

Comments (1)

janko avatar janko commented on June 1, 2024

See the "Other web servers" section in the README:

Other web servers

It's perfectly feasible to run tus-ruby-server on web servers other than Goliath or Unicorn (even necessary if you want to run it inside another app). Just keep in mind that most other web servers don't support request streaming, which means that tus-ruby-server will be able to start processing upload requess only once the whole request body has been received. Additionally, incomplete upload requests won't be forwarded to tus-ruby-server, so in order for resumable upload to be possible the client needs to send data in multiple upload requests (which can then be retried individually).

I realized now I could have explained it in a way that's directly actionable. Here it is:

Unless you're using Goliath, or Unicorn with Nginx buffering disabled, you'll have to:

  • Instruct your JS library (Uppy) to split the upload into chunks, which you should be able to do by specifying the chunkSize option to Uppy (5 * 1024 * 1024 = 5MB is good because it will work with tus-ruby-server's S3 storage). By default tus-js-client (which Uppy uses) will send a single upload request, which if the connection broke would never even reach tus-ruby-server (because Nginx will not forward it), which means you wouldn't be able to achieve resumable uploads.
  • Be vary of your disk space usage, because if you're using Puma, the uploaded data will be saved onto filesystem. Though you'll probably need to worry about that only if the traffic increases.
  • Be aware that the progress bar for the user might halt for a moment after each 5MB chunk is uploaded, because it needs to wait for tus-ruby-server to save uploaded data to its storage. In Goliath scenario the file is being saved while it's being uploaded, so there is no such delay.

With these things in mind, you can safely mount tus-ruby-server inside your Ruby app. You can either mount it in your config.ru:

# config.ru
require "tus/server"

map "/files" do
  run Tus::Server
end

run YourApp

or in config/routes.rb:

# config/initializers/tus_server.rb

require "tus/server"

# any tus-ruby-server configuration you want to put in here
# config/routes.rb
Rails.application.routes.draw do
  # ...
  mount Tus::Server => "/files"
end

from tus-ruby-server.

Related Issues (17)

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.