toamitkumar / ruby-multipart-post

Multipart Form Post through ruby script
9 stars 3 forks source link

Argument Error #1

Open unn4m3d opened 9 years ago

unn4m3d commented 9 years ago

Log

[INFO] Uploading /home/metal/.bot13_telegram/tmp/159126536
/var/lib/gems/2.1.0/gems/ruby-multipart-post-0.4.0/lib/stream.rb:17:in `read': wrong number of arguments (2 for 1) (ArgumentError)
    from /usr/lib/ruby/2.1.0/net/http/generic_request.rb:202:in `copy_stream'
    from /usr/lib/ruby/2.1.0/net/http/generic_request.rb:202:in `send_request_with_body_stream'
    from /usr/lib/ruby/2.1.0/net/http/generic_request.rb:132:in `exec'
    from /usr/lib/ruby/2.1.0/net/http.rb:1406:in `block in transport_request'
    from /usr/lib/ruby/2.1.0/net/http.rb:1405:in `catch'
    from /usr/lib/ruby/2.1.0/net/http.rb:1405:in `transport_request'
    from /usr/lib/ruby/2.1.0/net/http.rb:1378:in `request'
    from /var/lib/gems/2.1.0/gems/ruby-multipart-post-0.4.0/lib/multi_part_post.rb:44:in `block in submit'
    from /usr/lib/ruby/2.1.0/net/http.rb:853:in `start'
    from /var/lib/gems/2.1.0/gems/ruby-multipart-post-0.4.0/lib/multi_part_post.rb:44:in `submit'
    from /home/metal/.bot13_telegram/tgapi.rb:150:in `sendPhoto'
    from (eval):89:in `block in loadfile'
    from /home/metal/.bot13_telegram/api.rb:170:in `call'
    from /home/metal/.bot13_telegram/api.rb:170:in `execute'
    from ./core.rb:147:in `msgcb'
    from ./core.rb:205:in `block in <main>'
    from /home/metal/.bot13_telegram/tgapi.rb:78:in `call'
    from /home/metal/.bot13_telegram/tgapi.rb:78:in `call'
    from /home/metal/.bot13_telegram/tgapi.rb:165:in `block (2 levels) in update'
    from /home/metal/.bot13_telegram/tgapi.rb:161:in `each'
    from /home/metal/.bot13_telegram/tgapi.rb:161:in `block in update'
    from /home/metal/.bot13_telegram/tgapi.rb:160:in `each'
    from /home/metal/.bot13_telegram/tgapi.rb:160:in `update'
    from /home/metal/.bot13_telegram/tgapi.rb:103:in `main'
    from /home/metal/.bot13_telegram/tgapi.rb:113:in `block in start'
    from /var/lib/gems/2.1.0/gems/timers-4.0.1/lib/timers/timer.rb:97:in `call'
    from /var/lib/gems/2.1.0/gems/timers-4.0.1/lib/timers/timer.rb:97:in `fire'
    from /var/lib/gems/2.1.0/gems/timers-4.0.1/lib/timers/events.rb:43:in `fire'
    from /var/lib/gems/2.1.0/gems/timers-4.0.1/lib/timers/events.rb:85:in `block in fire'
    from /var/lib/gems/2.1.0/gems/timers-4.0.1/lib/timers/events.rb:84:in `reverse_each'
    from /var/lib/gems/2.1.0/gems/timers-4.0.1/lib/timers/events.rb:84:in `fire'
    from /var/lib/gems/2.1.0/gems/timers-4.0.1/lib/timers/group.rb:80:in `fire'
    from /var/lib/gems/2.1.0/gems/timers-4.0.1/lib/timers/group.rb:64:in `wait'
    from ./core.rb:229:in `block in <main>'
    from ./core.rb:229:in `loop'
    from ./core.rb:229:in `<main>'

Code :

def sendPhoto(chat_id,file,caption=nil,rtmi=nil,rmu=nil)
            sendChatAction(chat_id,"upload_photo")
            params = {
                "chat_id"=>chat_id.to_s,
                "photo"=>FileUploadIO.new(file,"image/jpeg")
            }
            puts "[INFO] Uploading #{file}"
            p = MultiPart::Post.new(params)
            p.submit("https://api.telegram.org/bot#{@token}/sendPhoto")
        end
bentimms commented 9 years ago

From what I can see, this is an incompatible with Ruby 2 and above. I have the same issue and am looking into how to resolve it.