lib/openstack/swift/storage_object.rb
def copy(object_name, container_name, headers = {})
      provided_headers = (headers[:metadata] || {}).inject({}){|res, (k,v)| ((k.to_s.match /^X-Object-Meta-/i) ? res[k.to_s]=v : res["X-Object-Meta-#{k.to_s}"]=v) ;res}
      provided_headers["content-type"] = headers[:content_type] unless headers[:content_type].nil?
      provided_headers["X-Copy-From"] = "/#{@containername}/#{@name}"
      provided_headers["content-length"] = "0"
      path = "/#{container_name}/#{object_name}"
      begin
        response = @container.swift.connection.req("PUT", URI.encode(path), {:headers=>provided_headers})
      rescue OpenStack::Exception::ItemNotFound => not_found
        msg = "Can't copy \"#{@name}\": No Object \"#{@name}\" found in Container \"#{@containername}\".  #{not_found.message}"
        raise OpenStack::Exception::ItemNotFound.new(msg, not_found.response_code, not_found.response_body)
      end
      OpenStack::Swift::StorageObject.new(@container.swift.container(container_name), object_name)
    end
# Copy this object to a new location (optionally in a new container)
#
# You must supply a name for the new object as well as a container name.
#
#    new_object = object.copy("new_obj", "my_container")
#
# You may also supply a hash of headers to set Content-Type, or custom
# key=>value metadata:
#optional headers: {
#                    :metadata=>{key=>value, key1=>value1, ...}
#                    :content_type=>content type of created object
#                  }
#
#    copied = object.copy('newfile.tmp', "my_container", {:content_type=>"text/plain", :metadata=>{:herp=>"derp", "X-Object-Meta-foo"=>"bar} } )
#    => => #<OpenStack::Swift::StorageObject:0xb728974c  .....
#
# Returns the new OpenStack::Swift::StorageObject for the copied item.
#
Copy this object to a new location (optionally in a new container)
You must supply a name for the new object as well as a container name.







Returns the new OpenStack::Swift::StorageObject for the copied item.
Copy this object to a new location ( optionally in a new container ) You must supply a name for the new object as well as a container name . Returns the new OpenStack :: Swift :: StorageObject for the copied item .
def copy(object_name, container_name, headers = {})
      provided_headers = (headers[:metadata] || {}).inject({}){|res, (k,v)| ((k.to_s.match /^X-Object-Meta-/i) ? res[k.to_s]=v : res["X-Object-Meta-#{k.to_s}"]=v) ;res}
      provided_headers["content-type"] = headers[:content_type] unless headers[:content_type].nil?
      provided_headers["X-Copy-From"] = "/#{@containername}/#{@name}"
      provided_headers["content-length"] = "0"
      path = "/#{container_name}/#{object_name}"
      begin
        response = @container.swift.connection.req("PUT", URI.encode(path), {:headers=>provided_headers})
      rescue OpenStack::Exception::ItemNotFound => not_found
        msg = "Can't copy \"#{@name}\": No Object \"#{@name}\" found in Container \"#{@containername}\".  #{not_found.message}"
        raise OpenStack::Exception::ItemNotFound.new(msg, not_found.response_code, not_found.response_body)
      end
      OpenStack::Swift::StorageObject.new(@container.swift.container(container_name), object_name)
    end
def copy ( object_name , container_name , headers = { } ) provided_headers = ( headers [ :metadata ] || { } ) . inject ( { } ) { | res , ( k , v ) | ( ( k . to_s . match / ^X-Object-Meta- /i ) ? res [ k . to_s ] = v : res [ "X-Object-Meta-#{k.to_s}" ] = v ) ; res } provided_headers [ "content-type" ] = headers [ :content_type ] unless headers [ :content_type ] . nil? provided_headers [ "X-Copy-From" ] = "/#{@containername}/#{@name}" provided_headers [ "content-length" ] = "0" path = "/#{container_name}/#{object_name}" begin response = @container . swift . connection . req ( "PUT" , URI . encode ( path ) , { :headers => provided_headers } ) rescue OpenStack :: Exception :: ItemNotFound => not_found msg = "Can't copy \"#{@name}\": No Object \"#{@name}\" found in Container \"#{@containername}\".  #{not_found.message}" raise OpenStack :: Exception :: ItemNotFound . new ( msg , not_found . response_code , not_found . response_body ) end OpenStack :: Swift :: StorageObject . new ( @container . swift . container ( container_name ) , object_name ) end
Copy this object to a new location (optionally in a new container)
You must supply a name for the new object as well as a container name.
Copy this object to a new location ( optionally in a new container ) You must supply a name for the new object as well as a container name .
object_name
container_name
headers