Advertisement
Guest User

Untitled

a guest
Jan 30th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.64 KB | None | 0 0
  1.   def upload
  2.     puts "Uploading..."
  3.  
  4.     @input.each {|file_name|
  5.       begin
  6.         req = Net::HTTP::Post.new(@uri, 'Content-Type' => 'application/json')
  7.         fi = File.open(@LOGS_DIR + "/" + file_name + "/20190128-214339.evtc", 'rb')
  8.  
  9.         req.body = {
  10.           json: '1',
  11.           rotation_weap1: '1',
  12.           generator: 'ei',
  13.           file: fi
  14.         }.to_json
  15.  
  16.         res = Net::HTTP.start(@uri.hostname, @uri.port, use_ssl: true) do |https|
  17.           https.request(req)
  18.         end
  19.  
  20.         p "response: #{res.body}"
  21.         fi.close
  22.       rescue => e
  23.         puts "Error during upload: #{e}"
  24.       end
  25.     }
  26.   end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement