Logo Search packages:      
Sourcecode: s3ql version File versions  Download package

def s3ql::backends::boto::s3::bucket::Bucket::copy_key (   self,
  new_key_name,
  src_bucket_name,
  src_key_name,
  metadata = None,
  src_version_id = None,
  storage_class = 'STANDARD',
  preserve_acl = False 
)
Create a new key in the bucket by copying another existing key.

:type new_key_name: string
:param new_key_name: The name of the new key

:type src_bucket_name: string
:param src_bucket_name: The name of the source bucket

:type src_key_name: string
:param src_key_name: The name of the source key

:type src_version_id: string
:param src_version_id: The version id for the key.  This param
               is optional.  If not specified, the newest
               version of the key will be copied.

:type metadata: dict
:param metadata: Metadata to be associated with new key.
         If metadata is supplied, it will replace the
         metadata of the source key being copied.
         If no metadata is supplied, the source key's
         metadata will be copied to the new key.

:type storage_class: string
:param storage_class: The storage class of the new key.
              By default, the new key will use the
              standard storage class.  Possible values are:
              STANDARD | REDUCED_REDUNDANCY

:type preserve_acl: bool
:param preserve_acl: If True, the ACL from the source key
             will be copied to the destination
             key.  If False, the destination key
             will have the default ACL.
             Note that preserving the ACL in the
             new key object will require two
             additional API calls to S3, one to
             retrieve the current ACL and one to
             set that ACL on the new object.  If
             you don't care about the ACL, a value
             of False will be significantly more
             efficient.

:rtype: :class:`boto.s3.key.Key` or subclass
:returns: An instance of the newly created key object

Definition at line 374 of file bucket.py.

                                                              :
        """
        Create a new key in the bucket by copying another existing key.

        :type new_key_name: string
        :param new_key_name: The name of the new key

        :type src_bucket_name: string
        :param src_bucket_name: The name of the source bucket

        :type src_key_name: string
        :param src_key_name: The name of the source key

        :type src_version_id: string
        :param src_version_id: The version id for the key.  This param
                               is optional.  If not specified, the newest
                               version of the key will be copied.

        :type metadata: dict
        :param metadata: Metadata to be associated with new key.
                         If metadata is supplied, it will replace the
                         metadata of the source key being copied.
                         If no metadata is supplied, the source key's
                         metadata will be copied to the new key.

        :type storage_class: string
        :param storage_class: The storage class of the new key.
                              By default, the new key will use the
                              standard storage class.  Possible values are:
                              STANDARD | REDUCED_REDUNDANCY

        :type preserve_acl: bool
        :param preserve_acl: If True, the ACL from the source key
                             will be copied to the destination
                             key.  If False, the destination key
                             will have the default ACL.
                             Note that preserving the ACL in the
                             new key object will require two
                             additional API calls to S3, one to
                             retrieve the current ACL and one to
                             set that ACL on the new object.  If
                             you don't care about the ACL, a value
                             of False will be significantly more
                             efficient.

        :rtype: :class:`boto.s3.key.Key` or subclass
        :returns: An instance of the newly created key object
        """
        if preserve_acl:
            acl = self.get_xml_acl(src_key_name)
        src = '%s/%s' % (src_bucket_name, urllib.quote(src_key_name))
        if src_version_id:
            src += '?version_id=%s' % src_version_id
        headers = {'x-amz-copy-source' : src}
        if storage_class != 'STANDARD':
            headers['x-amz-storage-class'] = storage_class
        if metadata:
            headers['x-amz-metadata-directive'] = 'REPLACE'
            headers = boto.utils.merge_meta(headers, metadata)
        else:
            headers['x-amz-metadata-directive'] = 'COPY'
        response = self.connection.make_request('PUT', self.name, new_key_name,
                                                headers=headers)
        body = response.read()
        if response.status == 200:
            key = self.new_key(new_key_name)
            h = handler.XmlHandler(key, self)
            xml.sax.parseString(body, h)
            if hasattr(key, 'Error'):
                raise S3CopyError(key.Code, key.Message, body)
            key.handle_version_headers(response)
            if preserve_acl:
                self.set_xml_acl(acl, new_key_name)
            return key
        else:
            raise S3ResponseError(response.status, response.reason, body)


Generated by  Doxygen 1.6.0   Back to index