Skip to content

Instantly share code, notes, and snippets.

@binarymason
Last active June 27, 2020 12:15
Show Gist options
  • Save binarymason/be003bbce617c471497efd28148e67a7 to your computer and use it in GitHub Desktop.
Save binarymason/be003bbce617c471497efd28148e67a7 to your computer and use it in GitHub Desktop.
upload multipart/form-data with net http
uri = URI("#{ODM}/task/new/upload/#{oid}")
request = Net::HTTP::Post.new(uri)
form_data = [
['images', attachment.tempfile, { filename: attachment.original_filename, content_type: attachment.content_type }]
]
request.set_form form_data, 'multipart/form-data'
response = Net::HTTP.start(uri.hostname, uri.port) do |http| # pay attention to use_ssl if you need it
http.request(request)
end
JSON.parse(response.body)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment