-
-
Save zealinux/0f28786a542c32245579720d51bdcecd to your computer and use it in GitHub Desktop.
faraday file upload
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'faraday' | |
field_file_url = 'http://localhost/blah' | |
file_to_upload = 'test.txt' | |
connection = Faraday.new(field_file_url) do |builder| | |
builder.request :multipart | |
builder.request :url_encoded | |
builder.adapter :net_http | |
end | |
payload = { file: Faraday::UploadIO.new(file_to_upload, 'text/plain') } | |
connection.post do |req| | |
req.body = payload | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment