10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/decode_xlog.rb', line 10
def self.decode(file_path)
url = URI("http://192.168.11.61:8080/decode")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
form_data = [['file', File.open(file_path)]]
request.set_form form_data, 'multipart/form-data'
response = http.request(request)
data = response.read_body
to_file_path = file_path + '.log'
file = File.new to_file_path, 'w+'
file.binmode
file << data
file.flush
file.close
puts file.path
end
|