Code Monkey home page Code Monkey logo

shrine-tus-demo's People

Contributors

dependabot[bot] avatar janko avatar mvasin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

mimosa naveen1336

shrine-tus-demo's Issues

Getting SSL error when submitting new file

I recently got interested about Tus + Falcon projects and stumbled upon your work, which looks promising but I am getting a Down::SSLError: SSL_connect returned=1 errno=0 state=error: certificate verify failed (self signed certificate) error when clicking the submit button.

Below is what I get in the console:

user$ bundle exec falcon serve
 0.44s: #<Falcon::Endpoint https://localhost:9292/>
      : Falcon taking flight! Using Async::Container::Forked with concurrency: 8
 0.44s: Full status: kill -USR1 -61523
 0.45s: Per-process status: kill -USR1 61791
 0.45s: Per-process status: kill -USR1 61790
 0.45s: Per-process status: kill -USR1 61792
 0.45s: Per-process status: kill -USR1 61793
 0.45s: Per-process status: kill -USR1 61794
 0.45s: Per-process status: kill -USR1 61795
 0.45s: Per-process status: kill -USR1 61796
 0.45s: Per-process status: kill -USR1 61797
 1.29s: <Async::Task:0x3fd35ad54720 failed>
      |  OpenSSL::SSL::SSLError: SSL_accept SYSCALL returned=5 errno=0 state=unknown state
      |  → /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/async-io-1.18.2/lib/async/io/generic.rb:141 in `accept_nonblock'
      |    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/async-io-1.18.2/lib/async/io/generic.rb:141 in `async_send'
      |    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/async-io-1.18.2/lib/async/io/generic.rb:47 in `block in wrap_blocking_method'
      |    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/async-io-1.18.2/lib/async/io/ssl_socket.rb:129 in `block in accept'
      |    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/async-1.15.1/lib/async/task.rb:199 in `block in make_fiber'
::1 - - [26/Jan/2019:20:36:02 +0900] "GET /movies " 200 998 0.0168
::1 - - [26/Jan/2019:20:36:02 +0900] "GET /assets/css/app.css " 200 74 0.0020
::1 - - [26/Jan/2019:20:36:02 +0900] "GET /assets/js/app.js " 200 1167 0.0013
::1 - - [26/Jan/2019:20:36:02 +0900] "GET /assets/css/app.css " 200 74 0.0012
::1 - - [26/Jan/2019:20:36:02 +0900] "GET /assets/js/app.js " 200 1167 0.0009
::1 - - [26/Jan/2019:20:36:03 +0900] "GET /movies/new " 200 1770 0.0047
::1 - - [26/Jan/2019:20:36:03 +0900] "GET /assets/css/app.css " 200 74 0.0009
::1 - - [26/Jan/2019:20:36:03 +0900] "GET /assets/js/app.js " 200 1167 0.0009
::1 - - [26/Jan/2019:20:36:03 +0900] "GET /assets/css/app.css " 200 74 0.0010
::1 - - [26/Jan/2019:20:36:03 +0900] "GET /assets/js/app.js " 200 1167 0.0010
13.83s: Down::SSLError: SSL_connect returned=1 errno=0 state=error: certificate verify failed (self signed certificate)
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/down-4.8.0/lib/down/http.rb:135:in `request_error!'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/down-4.8.0/lib/down/http.rb:100:in `rescue in send_request'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/down-4.8.0/lib/down/http.rb:91:in `send_request'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/down-4.8.0/lib/down/http.rb:86:in `request'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/down-4.8.0/lib/down/http.rb:72:in `open'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/down-4.8.0/lib/down/backend.rb:17:in `open'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/shrine-url-2.2.1/lib/shrine/storage/url.rb:23:in `open'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/shrine-tus-1.2.2/lib/shrine/storage/tus.rb:28:in `open'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/shrine-2.14.0/lib/shrine/uploaded_file.rb:96:in `open'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/shrine-2.14.0/lib/shrine/uploaded_file.rb:254:in `io'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/shrine-2.14.0/lib/shrine/uploaded_file.rb:156:in `read'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/shrine-2.14.0/lib/shrine/storage/file_system.rb:131:in `copy_stream'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/shrine-2.14.0/lib/shrine/storage/file_system.rb:131:in `upload'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/shrine-2.14.0/lib/shrine.rb:303:in `copy'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/shrine-2.14.0/lib/shrine.rb:292:in `put'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/shrine-2.14.0/lib/shrine.rb:276:in `_store'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/shrine-2.14.0/lib/shrine.rb:203:in `store'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/shrine-2.14.0/lib/shrine/plugins/hooks.rb:97:in `block in store'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/shrine-2.14.0/lib/shrine/plugins/hooks.rb:103:in `around_store'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/shrine-2.14.0/lib/shrine/plugins/hooks.rb:97:in `store'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/shrine-2.14.0/lib/shrine/plugins/logging.rb:91:in `block in store'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/shrine-2.14.0/lib/shrine/plugins/logging.rb:106:in `block in log'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/shrine-2.14.0/lib/shrine/plugins/logging.rb:167:in `benchmark'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/shrine-2.14.0/lib/shrine/plugins/logging.rb:106:in `log'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/shrine-2.14.0/lib/shrine/plugins/logging.rb:91:in `store'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/shrine-2.14.0/lib/shrine.rb:181:in `upload'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/shrine-2.14.0/lib/shrine/plugins/hooks.rb:58:in `block in upload'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/shrine-2.14.0/lib/shrine/plugins/hooks.rb:64:in `around_upload'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/shrine-2.14.0/lib/shrine/plugins/hooks.rb:58:in `upload'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/shrine-2.14.0/lib/shrine/attacher.rb:191:in `store!'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/shrine-2.14.0/lib/shrine/attacher.rb:123:in `promote'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/shrine-2.14.0/lib/shrine/attacher.rb:117:in `_promote'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/shrine-2.14.0/lib/shrine/attacher.rb:112:in `finalize'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/shrine-2.14.0/lib/shrine/plugins/sequel.rb:94:in `block (2 levels) in included'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sequel-5.16.0/lib/sequel/database/transactions.rb:423:in `each'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sequel-5.16.0/lib/sequel/database/transactions.rb:423:in `remove_transaction'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sequel-5.16.0/lib/sequel/database/transactions.rb:269:in `_transaction'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sequel-5.16.0/lib/sequel/database/transactions.rb:220:in `block in transaction'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sequel-5.16.0/lib/sequel/connection_pool/threaded.rb:92:in `hold'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sequel-5.16.0/lib/sequel/database/connecting.rb:270:in `synchronize'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sequel-5.16.0/lib/sequel/database/transactions.rb:186:in `transaction'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sequel-5.16.0/lib/sequel/model/base.rb:1905:in `checked_transaction'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sequel-5.16.0/lib/sequel/model/base.rb:1465:in `block in save'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sequel-5.16.0/lib/sequel/model/base.rb:1893:in `checked_save_failure'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sequel-5.16.0/lib/sequel/model/base.rb:1465:in `save'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sequel-5.16.0/lib/sequel/model/base.rb:254:in `create'
  /Users/user/Documents/shrine-tus-demo/app.rb:50:in `block (3 levels) in <class:ShrineTusDemo>'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/roda-3.16.0/lib/roda.rb:854:in `if_match'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/roda-3.16.0/lib/roda.rb:783:in `_verb'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/roda-3.16.0/lib/roda.rb:554:in `post'
  /Users/user/Documents/shrine-tus-demo/app.rb:49:in `block (2 levels) in <class:ShrineTusDemo>'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/roda-3.16.0/lib/roda.rb:854:in `if_match'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/roda-3.16.0/lib/roda.rb:520:in `on'
  /Users/user/Documents/shrine-tus-demo/app.rb:38:in `block in <class:ShrineTusDemo>'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/roda-3.16.0/lib/roda.rb:282:in `instance_exec'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/roda-3.16.0/lib/roda.rb:282:in `block in call'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/roda-3.16.0/lib/roda.rb:280:in `catch'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/roda-3.16.0/lib/roda.rb:280:in `call'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/roda-3.16.0/lib/roda.rb:243:in `block in build_rack_app'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/rack-2.0.6/lib/rack/common_logger.rb:33:in `call'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/rack-2.0.6/lib/rack/sendfile.rb:111:in `call'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/rack-2.0.6/lib/rack/method_override.rb:22:in `call'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/roda-3.16.0/lib/roda.rb:137:in `call'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/falcon-0.21.0/lib/falcon/adapters/rack.rb:173:in `call'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/async-http-0.37.12/lib/async/http/middleware.rb:57:in `call'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/falcon-0.21.0/lib/falcon/adapters/rewindable.rb:61:in `call'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/async-http-0.37.12/lib/async/http/middleware.rb:57:in `call'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/async-http-0.37.12/lib/async/http/content_encoding.rb:44:in `call'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/async-http-0.37.12/lib/async/http/middleware.rb:57:in `call'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/async-http-0.37.12/lib/async/http/server.rb:61:in `block in accept'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/async-http-0.37.12/lib/async/http/protocol/http2/server.rb:63:in `each'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/async-http-0.37.12/lib/async/http/server.rb:50:in `accept'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/async-io-1.18.2/lib/async/io/socket.rb:95:in `block in accept_each'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/async-io-1.18.2/lib/async/io/ssl_socket.rb:131:in `block in accept'
  /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/async-1.15.1/lib/async/task.rb:199:in `block in make_fiber'
13.83s: <Async::Task:0x3fd35ad54608 failed>
      |  OpenSSL::SSL::SSLError: SSL_accept returned=1 errno=0 state=unknown state: tlsv1 alert unknown ca
      |  → /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/async-io-1.18.2/lib/async/io/generic.rb:141 in `accept_nonblock'
      |    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/async-io-1.18.2/lib/async/io/generic.rb:141 in `async_send'
      |    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/async-io-1.18.2/lib/async/io/generic.rb:47 in `block in wrap_blocking_method'
      |    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/async-io-1.18.2/lib/async/io/ssl_socket.rb:129 in `block in accept'
      |    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/async-1.15.1/lib/async/task.rb:199 in `block in make_fiber'

Timeout when updating attachment data

Hi,

Thanks for all your work on these gems.

I am following this demo to try to get shrine working with tus on Rails with s3 storage.

gem 'shrine', "~> 2.8.0"
gem 'shrine-tus', "~> 1.1.0"
gem 'tus-server', "~> 2.0.2"

However, I am getting the following error when posting the attachment data, after a long delay, suggesting in fact it is timing out trying to download the attachment from the tus server:

18:03:25 web.1       | timed out while reading data excluded from capture: Not configured to send/capture in environment 'development'
18:03:25 web.1       |   
18:03:25 web.1       | Down::TimeoutError (timed out while reading data):
18:03:25 web.1       |   
18:03:25 web.1       | down (4.2.1) lib/down/net_http.rb:251:in `request_error!'
18:03:25 web.1       | down (4.2.1) lib/down/net_http.rb:169:in `rescue in net_http_request'
18:03:25 web.1       | down (4.2.1) lib/down/net_http.rb:159:in `net_http_request'
18:03:25 web.1       | down (4.2.1) lib/down/net_http.rb:82:in `block in open'

Here is an example of the attachment data I'm posting:

{"id":"http://ocalhost:5000/[...]/ecd34e90ba03b1415db65e382dc87727","storage":"cache","metadata":{"filename":"file.pdf","mime_type":"application/pdf","size":1289}}

When I copy and paste that URL in my browser, the file downloads just fine.

Here are what I think are the relative parts of my shrine config:

Tus::Server.opts[:storage] = Tus::Storage::S3.new(prefix: "tus", **s3_options)

  Shrine.storages = {
    local_cache: Shrine::Storage::FileSystem.new('public', prefix: "uploads/#{Rails.env}/"),
    cache: Shrine::Storage::S3.new(prefix: 'cache', **s3_options), 
    store: Shrine::Storage::S3.new(prefix: 'store', **s3_options),
    tus:   Shrine::Storage::Tus.new
  }

These configs were working fine before adding the tus store.

Any insight you can give would be greatly appreciated!

Tests are missing

Janko, can you please add some tests, to give an idea on how would you approach to testing such an application? I'm interested in higher level, functional/integration testing.

Aws::S3::Errors::NoSuchKey when both tus and Shrine storages are on S3

I forked this repo and created a branch, where I carefully reproduced instructions for case when tus-server and Shrine are both on S3 (optimized version, with file id substitution in Roda tree).

The problem is: if I upload a file, then delete it, then upload the same file once again, I get

E, [2017-04-09T16:24:25.469177 #524] ERROR -- : Sucker Punch job error for class: 'PromoteJob' args: [{"attachment"=>"{\"storage\":\"cache\",\"id\":\"b711b7274ee5f8539107b51a975b78db\",\"metadata\":{\"filename\":\"18-jquery-ujs-callbacks.mp4\",\"size\":22467168,\"mime_type\":\"video/mp4\"}}", "record"=>["Movie", "2"], "name"=>"video", "shrine_class"=>"VideoUploader", "action"=>"store", "phase"=>"store"}]
Aws::S3::Errors::NoSuchKey The specified key does not exist.

Here are the details. I start with clean S3 bucket and clean postgresql, then upload one file. It gets promoted:

mvasin$ aws s3 ls s3://ntv.test --recursive
2017-04-09 19:18:35   22467168 store/64f4170bddc1ac17d5a0a2dc66eadf7c.mp4
2017-04-09 19:18:26        244 tus/b711b7274ee5f8539107b51a975b78db.info

Then I delete this file (from within Roda app). S3 looks like this:

mvasin$ aws s3 ls s3://ntv.test --recursive
2017-04-09 19:18:26        244 tus/b711b7274ee5f8539107b51a975b78db.info

No problems (yet).

Then I upload the same file once again, progress bar runs till the end, no errors in browser's JS console. But S3 looks like nothing was uploaded:

mvasin$ aws s3 ls s3://ntv.test --recursive
2017-04-09 19:18:26        244 tus/b711b7274ee5f8539107b51a975b78db.info

I hit 'Submit' and get Aws::S3::Errors::NoSuchKey above in error in Roda logs. S3 looks the same (just .info file), and, of course, there is a 404 error for https://s3-eu-west-1.amazonaws.com/ntv.test/tus/b711b7274ee5f8539107b51a975…Signature=02866c55e4d48eb0ce7dde941b73e4c12eb40c25689c4f1be8f00301c0b3fddf file at http://localhost:9292/movies.

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.