Class: Pansophy::Remote::CreateFile

Inherits:
Object
  • Object
show all
Includes:
Adamantium::Flat
Defined in:
lib/pansophy/remote/create_file.rb

Constant Summary collapse

ALLOWED_ATTRS =
%i[
  cache_control
  content_disposition
  content_encoding
  content_length
  content_md5
  content_type
  etag
  expires
  last_modified
  metadata
  owner
  storage_class
  encryption
  encryption_key
  version
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(bucket, path, body) ⇒ CreateFile

Returns a new instance of CreateFile.



24
25
26
27
28
# File 'lib/pansophy/remote/create_file.rb', line 24

def initialize(bucket, path, body)
  @bucket   = bucket
  @pathname = Pathname.new(path)
  @body     = body
end

Instance Method Details

#call(options = {}) ⇒ Object



30
31
32
33
34
# File 'lib/pansophy/remote/create_file.rb', line 30

def call(options = {})
  prevent_overwrite! unless options[:overwrite]
  file_attributes = options.slice(*ALLOWED_ATTRS)
  directory.files.create(file_attributes.merge(key: @pathname.to_s, body: @body.dup))
end