96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
# File 'lib/openc3/utilities/target_file.rb', line 96
def self.body(scope, name)
name = name.split('*')[0] if ENV['OPENC3_LOCAL_MODE']
local_file = OpenC3::LocalMode.open_local_file(name, scope: scope)
if local_file
if File.extname(name) == ".bin"
return local_file.read
else
return local_file.read.force_encoding('UTF-8')
end
end
end
bucket = Bucket.getClient()
resp = bucket.get_object(bucket: ENV['OPENC3_CONFIG_BUCKET'], key: "#{scope}/targets_modified/#{name}")
unless resp
resp = bucket.get_object(bucket: ENV['OPENC3_CONFIG_BUCKET'], key: "#{scope}/targets/#{name}")
end
if resp && resp.body
if File.extname(name) == ".bin"
resp.body.binmode
return resp.body.read
else
return resp.body.read.force_encoding('UTF-8')
end
else
nil
end
end
|