Skip to content

Instantly share code, notes, and snippets.

@gr33n7007h
Created December 14, 2018 11:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gr33n7007h/beb927353dddfd5c9e7a41ddee93bba2 to your computer and use it in GitHub Desktop.
Save gr33n7007h/beb927353dddfd5c9e7a41ddee93bba2 to your computer and use it in GitHub Desktop.
require 'net/http'
uri = URI.parse("https://mydomain.com/attachments")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Got this"
req_options = {
use_ssl: uri.scheme == "https",
}
form_data = [['readme', File.open('README.md')]]
request.set_form form_data, 'multipart/form-data'
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
http.request(request)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment