通过rails上传大(2Gb +)文件

时间:2018-04-11 11:13:40

标签: ruby-on-rails ruby file-upload rest-client

我的服务器上有大文件,需要通过http(s)将它们发送到另一台服务器。 我用rest-client gem 它适用于小文件,但2 + Gb文件会导致错误。

当我尝试使用https时,我收到了此错误

RangeError: integer 2325958991 too big to convert to `int'

使用本地http测试并收到此错误

2.3.3 :001 > RestClient.post 'http://localhost:4567/upload',  :my_file => File.open("test_file2G", 'rb')                                                                                                                                  
Errno::EPIPE: Broken pipe
        from /home/rubydev/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/net/protocol.rb:211:in `write'
        from /home/rubydev/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/net/protocol.rb:211:in `write0'
        from /home/rubydev/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/net/protocol.rb:185:in `block in write'
        from /home/rubydev/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/net/protocol.rb:202:in `writing'
        from /home/rubydev/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/net/protocol.rb:184:in `write'
        from /home/rubydev/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/net/http/generic_request.rb:188:in `send_request_with_body'
        from /home/rubydev/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/net/http/generic_request.rb:121:in `exec'

对于我使用sinatra服务器的测试,它成功地接收了检查表格卷曲的大文件。

UPDATE 流式上传会导致相同的错误

1 个答案:

答案 0 :(得分:0)

宝石curb成功发送大文件