Method: OpenC3::TargetFile.create

Defined in:
lib/openc3/utilities/target_file.rb

.create(scope, name, text, content_type: 'text/plain') ⇒ Object



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/openc3/utilities/target_file.rb', line 114

def self.create(scope, name, text, content_type: 'text/plain')
  return false unless text
  if ENV['OPENC3_LOCAL_MODE']
    OpenC3::LocalMode.put_target_file("#{scope}/targets_modified/#{name}", text, scope: scope)
  end
  OpenC3::S3Utilities.put_object_and_check(
    # Use targets_modified to save modifications
    # This keeps the original target clean (read-only)
    key: "#{scope}/targets_modified/#{name}",
    body: text,
    bucket: DEFAULT_BUCKET_NAME,
    content_type: content_type,
  )
  true
end