Object
Take in a path and return a key
# File lib/haste/uploader.rb, line 19 def upload_path(path) fail_with 'No input file given' unless path fail_with "#{path}: No such path" unless File.exists?(path) upload_raw open(path).read end
Take in data and return a key
# File lib/haste/uploader.rb, line 26 def upload_raw(data) data.rstrip! response = do_post data if response.status == 200 data = JSON.parse(response.body) data['key'] else fail_with "failure uploading: #{response.body}" end rescue JSON::ParserError => e fail_with "failure parsing response: #{e.message}" rescue Errno::ECONNREFUSED => e fail_with "failure connecting: #{e.message}" end
Generated with the Darkfish Rdoc Generator 2.