How to download a video file from httparty

Hi, I saw httparty, but I have no idea how to implement it, there are many examples of the model file, but which parameter can be used to upload the video file.

+5
source share
3 answers

HTTMultiParty supports file downloads by publishing a multi-page MIME document. It wraps HTTParty, so you use it the same way. For the file, just put the File object. Example from README:

require 'httmultiparty'
class SomeClient
  include HTTMultiParty
  base_uri 'http://localhost:3000'
end

response = SomeClient.post('/', :query => {
  :foo      => 'bar',
  :somefile => File.new('README.md')
})
+6
source
+1

Using the RestClient stone, we can easily handle file downloads, but make sure you install the rest-client stone.

And I also added a screenshot from an example request from a postman.

And the code in the controller, as shown below,

  res = RestClient::Request.execute(
      method: :post,
      url: "http://www.your_url.com",
      payload: params,

      headers: {
          'Content-Type' => "multipart/form-data",
          Authorization: "some_key",
          :Accept => "*/*"
      }

  )

enter image description here

+1
source

All Articles