Ejemplo n.º 1
0
 def _delete_key_internal(self,
                          key_name,
                          headers=None,
                          version_id=None,
                          mfa_token=None,
                          query_args_l=None):
     query_args_l = query_args_l or ""
     provider = self.connection.provider
     if version_id:
         query_args_l.append('versionId=%s' % version_id)
     query_args = '&'.join(query_args_l) or None
     if mfa_token:
         if not headers:
             headers = {}
         headers[provider.mfa_header] = ' '.join(mfa_token)
     response = self.connection.make_request('DELETE',
                                             self.name,
                                             key_name,
                                             headers=headers,
                                             query_args=query_args)
     body = response.read()
     if response.status != 204:
         raise provider.storage_response_error(response.status,
                                               response.reason, body)
     else:
         # return a key object with information on what was deleted.
         k = Key(self)
         k.name = key_name
         k.handle_version_headers(response)
         k.handle_addl_headers(response.getheaders())
         return k
Ejemplo n.º 2
0
 def _get_key_internal(self, key_name, headers, query_args_l):
     query_args = query_args_l or None
     response = self.connection.make_request('HEAD', self.name, key_name,
                                             headers=headers,
                                             query_args=query_args)
     response.read()
     # Allow any success status (2xx) - for example this lets us
     # support Range gets, which return status 206:
     if response.status / 100 == 2:
         k = Key(self)
         #provider = self.connection.provider
         #k.metadata = boto.utils.get_aws_metadata(response.msg, provider)
         for field in Key.base_fields:
             k.__dict__[field.lower().replace('-', '_')] = \
                 response.getheader(field)
         # the following machinations are a workaround to the fact that
         # apache/fastcgi omits the content-length header on HEAD
         # requests when the content-length is zero.
         # See http://goo.gl/0Tdax for more details.
         clen = response.getheader('content-length')
         if clen:
             k.size = int(response.getheader('content-length'))
         else:
             k.size = 0
         k.name = key_name
         k.handle_version_headers(response)
         k.handle_encryption_headers(response)
         k.handle_restore_headers(response)
         k.handle_addl_headers(response.getheaders())
         return k, response
     else:
         if response.status == 404:
             return None, response
         else:
             raise S3ResponseError(response.status, response.reason, response.body)
Ejemplo n.º 3
0
 def _delete_key_internal(self, key_name, headers=None, version_id=None,
                          mfa_token=None, query_args_l=None):
     query_args_l = query_args_l or ""
     provider = self.connection.provider
     if version_id:
         query_args_l.append('versionId=%s' % version_id)
     query_args = '&'.join(query_args_l) or None
     if mfa_token:
         if not headers:
             headers = {}
         headers[provider.mfa_header] = ' '.join(mfa_token)
     response = self.connection.make_request('DELETE', self.name, key_name,
                                             headers=headers,
                                             query_args=query_args)
     body = response.read()
     if response.status != 204:
         raise provider.storage_response_error(response.status,
                                               response.reason, body)
     else:
         # return a key object with information on what was deleted.
         k = Key(self)
         k.name = key_name
         k.handle_version_headers(response)
         k.handle_addl_headers(response.getheaders())
         return k
Ejemplo n.º 4
0
 def _get_key_internal(self, key_name, headers, query_args_l):
     query_args = query_args_l or None
     response = self.connection.make_request('HEAD', self.name, key_name,
                                             headers=headers,
                                             query_args=query_args)
     response.read()
     # Allow any success status (2xx) - for example this lets us
     # support Range gets, which return status 206:
     if response.status / 100 == 2:
         k = Key(self)
         #provider = self.connection.provider
         #k.metadata = boto.utils.get_aws_metadata(response.msg, provider)
         for field in Key.base_fields:
             k.__dict__[field.lower().replace('-', '_')] = \
                 response.getheader(field)
         # the following machinations are a workaround to the fact that
         # apache/fastcgi omits the content-length header on HEAD
         # requests when the content-length is zero.
         # See http://goo.gl/0Tdax for more details.
         clen = response.getheader('content-length')
         if clen:
             k.size = int(response.getheader('content-length'))
         else:
             k.size = 0
         k.name = key_name
         k.handle_version_headers(response)
         k.handle_encryption_headers(response)
         k.handle_restore_headers(response)
         k.handle_addl_headers(response.getheaders())
         return k, response
     else:
         if response.status == 404:
             return None, response
         else:
             raise S3ResponseError(response.status, response.reason, None)