def copy(options = {})
raise CloudFiles::Exception::Syntax, "You must provide the :container, :name, or :headers for this operation" unless (options[:container] || options[:name] || options[:headers])
new_container = options[:container] || self.container.name
new_name = options[:name] || self.name
new_headers = options[:headers] || {}
raise CloudFiles::Exception::Syntax, "The :headers option must be a hash" unless new_headers.is_a?(Hash)
new_name.sub!(/^\//,'')
headers = {'X-Copy-From' => "#{self.container.name}/#{self.name}", 'Content-Type' => self.content_type.sub(/;.+/, '')}.merge(new_headers)
new_path = "#{CloudFiles.escape new_container}/#{escape_name new_name}"
begin
response = SwiftClient.put_object(self.container.connection.storageurl, self.container.connection.authtoken, (CloudFiles.escape new_container), escape_name(new_name), nil, nil, nil, nil, nil, headers)
return CloudFiles::Container.new(self.container.connection, new_container).object(new_name)
rescue ClientException => e
code = e.status.to_s
raise CloudFiles::Exception::InvalidResponse, "Invalid response code #{response.code}" unless (response.code =~ /^20/)
end
end