lib/tori/backend/s3.rb in tori-0.6.6 vs lib/tori/backend/s3.rb in tori-0.7.0

- old
+ new

@@ -55,10 +55,14 @@ opts ||= {} if from_path = opts.delete(:from_path) opts[:content_type] = self.class.type_for(from_path) end + if resource.nil? && opts[:body] + resource = opts[:body] + end + case resource when String put_object({ key: filename, body: resource, @@ -119,10 +123,19 @@ else head_bucket end end + def copy_to(filename, tori_file, **opts) + copy_object( + copy_source: "#{bucket}/#{filename}", + bucket: backend.bucket, + key: tori_file.name, + **opts, + ) + end + def public_url(filename) "#{client.config.endpoint}/#{@bucket}/#{filename}" end def url_for(filename, method) @@ -166,9 +179,13 @@ client.put_object bucket: @bucket, **opts end def delete_object(opts={}) client.delete_object bucket: @bucket, **opts + end + + def copy_object(opts = {}) + client.copy_object bucket: @bucket, **opts end end end end