35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/hawkular/operations/operations_api.rb', line 35
def to_msg_hash
operation_name, json = split('=', 2)
magic_bits = [
"\x50\x4B\x03\x04",
"\x50\x4B\x05\x06",
"\x50\x4B\x07\x08"
]
search_chunk = json[0, 102_400]
zip_file = nil
magic_bits.each do |bits|
idx = search_chunk.index(bits)
next unless idx
zip_file = json[idx..-1]
json = json[0, idx]
break
end
json = JSON.parse(json)
json[:attachments] = zip_file
{ operationName: operation_name, data: json }
rescue
{}
end
|