Ejemplo n.º 1
0
 def list_buckets(**_):
     """oss2.Service.list_buckets"""
     response = storage_mock.get_locators()
     buckets = []
     for name, headers in response.items():
         bucket = HeadObjectResult(Response(headers=headers))
         bucket.name = name
         buckets.append(bucket)
     return ListResult(buckets=buckets)
Ejemplo n.º 2
0
        def list_objects(self, prefix=None, max_keys=None, **_):
            """oss2.Bucket.list_objects"""
            response = storage_mock.get_locator(
                self._bucket_name, prefix=prefix, limit=max_keys,
                raise_404_if_empty=False)
            object_list = []
            for key, headers in response.items():
                obj = HeadObjectResult(Response(headers=headers))
                obj.key = key
                object_list.append(obj)

            return ListResult(object_list=object_list)
Ejemplo n.º 3
0
 def head_object(self, key=None, **_):
     """oss2.Bucket.head_object"""
     headers = storage_mock.head_object(self._bucket_name, key)
     if "_target" in headers:
         headers["x-oss-object-type"] = "Symlink"
         headers["type"] = "Symlink"
     return HeadObjectResult(Response(headers=headers))
Ejemplo n.º 4
0
 def upload_part(self,
                 key=None,
                 upload_id=None,
                 part_number=None,
                 data=None,
                 **_):
     """oss2.Bucket.upload_part"""
     assert upload_id == "123"
     return HeadObjectResult(
         Response(
             headers=storage_mock.put_object(self._bucket_name, key +
                                             str(part_number), data)))
Ejemplo n.º 5
0
 def head_object(self, key=None, **_):
     """oss2.Bucket.head_object"""
     return HeadObjectResult(Response(
         headers=storage_mock.head_object(self._bucket_name, key)))