Method: FileHelper#post_file
- Defined in:
- lib/bearcat/client/file_helper.rb
#post_file(url, params, file_path) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/bearcat/client/file_helper.rb', line 14 def post_file(url, params, file_path) params['Filename'] = File.basename(file_path) params['file'] = Faraday::UploadIO.new(file_path, params['content-type']) response = upload_connection.post(url, params) if [302, 303].include? response.status #success if it is a redirect response.headers['Location'] else raise 'FailedFileUpload' end end |