I am currently trying to store a pdf in a hash for an api call in ruby. The path to the pdf is stored as:

```
/Users/myUserName/Desktop/REPOSITORY/path_to_file.pdf

```

I am using a block to store the file in the hash as so:

```
File.open(pdf_location, "rb") do |file|
        params = {
          other irrelevant entries
          :document => file
        }
        pdf_upload_request('post', params, headers)
end

```

I am receiving a 400 error from the server that my document is empty and when I do `puts file.read`, it is empty. However, when I visit the filepath, it's clear that the file is not empty. Am I missing something here? Any help would be greatly appreciated. Thank you!

Edit------

I recorded my http request with vcr, here it is:

```
request:
    method: post
    uri: request_uri
    body:
      encoding: US-ASCII
      string: ''
    headers:
      Authorization:
      - Bearer 3ZOCPnwfoN7VfdGh7k4lrBuEYs4gN1
      Content-Type:
      - multipart/form-data; boundary=-----------RubyMultipartPost
      Content-Length:
      - '246659'

```

So i don't think the issue is with me sending the file with multipart encoding

Update--------

The filepaths to the pdf are generated from a url, and stored in a the tmp folder of my application. They are generated through this method:

```
def get_temporary_pdf(chrono_detail, recording, host)
    auth_token = User.find(chrono_detail.user_id).authentication_token
      # pdf_location = "https://54.84.224.252/recording/5/analysis.pdf/?token=Ybp37kw7HrSt8NyyPnBZ"
    pdf_location = host + '/recordings/' + recording.id.to_s + '/analysis.pdf/?format=pdf&download=true&token=' + auth_token
    filename = "Will" + '_' + recording.id.to_s + '_' + Date.new.to_s + '.pdf'
    Thread.new do
      File.open(Rails.root.join("tmp",filename), "wb") do |file|
        file.write(open(pdf_location, {ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE}).read)
      end
    end
    Rails.root.join("tmp",filename)
  end 

```

They are then called using the api call:

```
client.upload_document(patient_id, file_path, description)

```

I can see them physically in my temp folder, and can view them with preview. Everything seems to work. But as a test of uncertainty, I changed file\_path to point to a different pdf:

```
Users/myUsername/Desktop/example.pdf.

```

Using this file path worked. The pdf was uploaded to the third party system correctly, I can physically see it there. Do you think this means it is an issue with the tmp folder or how i generate the temporary pdf's?