main.rb681 chars29 lines
In this example, we use the Net::HTTP
library to send a post request with multipart/form-data
, which is commonly used for uploading files. We create a new Net::HTTP::Post
object and set the Content-Type header to multipart/form-data
. We then set the file field using the UploadIO
class which takes the file path and content type as arguments. Finally, we can set any additional fields using the set_form_data
method. The response is received and printed to the console.
gistlibby LogSnag