I-am-simple-user I-am-simple-user - 2 years ago 180
Ruby Question

Getting Connection reset by peer - SSL_connect error while uploding file to another app

Currently I have a rails application. Now I have to implement functionality to upload a file to another application.

The given application uses 3-legged oauth for security.
They have following architecture

I have able to create the FileID. But while making PUT call (uploading file) getting the
Errno::ECONNRESET: Connection reset by peer - SSL_connect

So how can I upload the file in chunk. Here is my sample code for uploading file.

file_data = File.open("/home/test/Downloads/RechargeReceipt.pdf") {|io| io.read}
file_data_64 = Base64.encode64(file_data)

{ 'Content' => file_data_64 }.to_json,
'Accept' => 'application/vnd.axiom.v3+json',
'Content-Type' => 'application/octet-stream'

I am using rails 4.

Answer Source

There is an issue while passing the body parameters.

data = File.read(params[:file].path)
          'Accept' => JohnDeere::ACCEPT,
          'Content-Type' => content_type
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download