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.

Revisions

  1. binarymason revised this gist Jun 27, 2020. No changes.
  2. binarymason created this gist Jun 27, 2020.
    13 changes: 13 additions & 0 deletions upload.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    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)