I-am-simple-user I-am-simple-user - 6 months ago 69
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
error.

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)

access_token.put("/org/files/3156906966",
{ 'Content' => file_data_64 }.to_json,
{
'Accept' => 'application/vnd.axiom.v3+json',
'Content-Type' => 'application/octet-stream'
}
)


I am using rails 4.

Answer

There is an issue while passing the body parameters.

data = File.read(params[:file].path)
access_token.put("/org/files/#{file_id}",
        data,
        {
          'Accept' => JohnDeere::ACCEPT,
          'Content-Type' => content_type
        }
      )
Comments