Method: TpCommon::FileStorage::Uploaders::Public#upload

Defined in:
lib/tp_common/file_storage/uploaders/public.rb

#upload(file_key, content, _content_type = nil) ⇒ Object

Upload content to file_key Currently, _content_type is ignore but kept for compatible. Will be removed in next release



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/tp_common/file_storage/uploaders/public.rb', line 11

def upload(file_key, content, _content_type = nil)
  retry_count = 0

  begin
    directory.files.create(
      key: mask_key(file_key),
      body: content,
      public: true)
  rescue StandardError => e
    retry_count += 1
    retry if retry_count < MAX_RETRIES
    raise e
  end

  mask_key(file_key)
end