lib/pansophy/remote/create_file.rb in pansophy-0.5.5 vs lib/pansophy/remote/create_file.rb in pansophy-0.5.6
- old
+ new
@@ -1,18 +1,39 @@
+require 'facets/hash/slice'
+
module Pansophy
module Remote
class CreateFile
include Adamantium::Flat
+ 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
+
def initialize(bucket, path, body)
@bucket = bucket
@pathname = Pathname.new(path)
@body = body
end
def call(options = {})
prevent_overwrite! unless options[:overwrite]
- directory.files.create(key: @pathname.to_s, body: @body.dup)
+ file_attributes = options.slice(*ALLOWED_ATTRS)
+ directory.files.create(file_attributes.merge(key: @pathname.to_s, body: @body.dup))
end
private
def exist?