lib/s3/right_s3_interface.rb
# Deletes multiple keys. Returns an array with errors, if any.
#
#  s3.delete_multiple('my_awesome_bucket', ['key1', 'key2', ...)
#    #=> [ { :key => 'key2', :code => 'AccessDenied', :message => "Access Denied" } ]
#
Deletes multiple keys. Returns an array with errors, if any.
Deletes multiple keys . Returns an array with errors if any .
def delete_multiple(bucket, keys=[], headers={})
      errors = []
      keys = Array.new(keys)
      while keys.length > 0
        data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
        data += "<Delete>\n<Quiet>true</Quiet>\n"
        keys.take(MULTI_OBJECT_DELETE_MAX_KEYS).each do |key|
          data += "<Object><Key>#{AwsUtils::xml_escape(key)}</Key></Object>\n"
        end
        data += "</Delete>"
        req_hash = generate_rest_request('POST', headers.merge(
          :url  => "#{bucket}?delete",
          :data => data,
          'content-md5' => AwsUtils::content_md5(data)
        ))
        errors += request_info(req_hash, S3DeleteMultipleParser.new)
        keys = keys.drop(MULTI_OBJECT_DELETE_MAX_KEYS)
      end
      errors
    rescue
      on_exception
    end
def delete_multiple ( bucket , keys = [ ] , headers = { } ) errors = [ ] keys = Array . new ( keys ) while keys . length > 0 data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" data += "<Delete>\n<Quiet>true</Quiet>\n" keys . take ( MULTI_OBJECT_DELETE_MAX_KEYS ) . each do | key | data += "<Object><Key>#{AwsUtils::xml_escape(key)}</Key></Object>\n" end data += "</Delete>" req_hash = generate_rest_request ( 'POST' , headers . merge ( :url => "#{bucket}?delete" , :data => data , 'content-md5' => AwsUtils :: content_md5 ( data ) ) ) errors += request_info ( req_hash , S3DeleteMultipleParser . new ) keys = keys . drop ( MULTI_OBJECT_DELETE_MAX_KEYS ) end errors rescue on_exception end
Deletes multiple keys.
Deletes multiple keys .
bucket
<not_specific>
keys
<not_specific>
headers
<not_specific>