# Path: qingcloud/qingstor/exception.py
# def get_response_error(response, body=None):
#     if not body:
#         body = response.read()
#     args = {
#         "status": response.status,
#         "body": body,
#         "request_id": response.getheader("request_id")
#     }
#     if body:
#         try:
#             resp = load_data(body)
#             args["code"] = resp["code"]
#             args["message"] = resp["message"]
#             args["url"] = resp["url"]
#         except ValueError:
#             pass
#     return QSResponseError(**args)
# 
# Path: qingcloud/qingstor/util.py
# def load_data(data):
#     """ Wrapper to load json data, to be compatible with Python3.
#     Returns: JSON data
# 
#     Keyword arguments:
#     data: might be bytes or str
#     """
#     if type(data) == bytes:
#         return json.loads(data.decode("utf-8"))
#     else:
#         return json.loads(data)


from .exception import get_response_error
from .util import load_data
            "part_number": str(part_number),
        }
        response = self.bucket.connection.make_request(
            "PUT", self.bucket.name, self.key_name, data=fp, params=params)
        if response.status == 201:
            part = Part(self.bucket.name, self.key_name, part_number)
            return part
        else:
            err = get_response_error(response)
            raise err

    def get_all_parts(self):
        """ Retrieve all multiparts of an object that uploaded.
        """
        params = {
            "upload_id": self.upload_id,
        }
        response = self.bucket.connection.make_request(
            "GET", self.bucket.name, self.key_name, params=params)
        if response.status == 200:
            parts = []
            resp = load_data(response.read())
            for item in resp["object_parts"]:
                part = Part(self.bucket.name, self.key_name,
                            item["part_number"])
                part.size = item["size"]
                part.created = item["created"]
                parts.append(part)
            return parts
        else:

# Path: qingcloud/qingstor/exception.py
# def get_response_error(response, body=None):
#     if not body:
#         body = response.read()
#     args = {
#         "status": response.status,
#         "body": body,
#         "request_id": response.getheader("request_id")
#     }
#     if body:
#         try:
#             resp = load_data(body)
#             args["code"] = resp["code"]
#             args["message"] = resp["message"]
#             args["url"] = resp["url"]
#         except ValueError:
#             pass
#     return QSResponseError(**args)
# 
# Path: qingcloud/qingstor/util.py
# def load_data(data):
#     """ Wrapper to load json data, to be compatible with Python3.
#     Returns: JSON data
# 
#     Keyword arguments:
#     data: might be bytes or str
#     """
#     if type(data) == bytes:
#         return json.loads(data.decode("utf-8"))
#     else:
#         return json.loads(data)


# Path: qingcloud/qingstor/multipart.py
from .exception import get_response_error
from .util import load_data

            "part_number": str(part_number),
        }
        response = self.bucket.connection.make_request(
            "PUT", self.bucket.name, self.key_name, data=fp, params=params)
        if response.status == 201:
            part = Part(self.bucket.name, self.key_name, part_number)
            return part
        else:
            err = get_response_error(response)
            raise err

    def get_all_parts(self):
        """ Retrieve all multiparts of an object that uploaded.
        """
        params = {
            "upload_id": self.upload_id,
        }
        response = self.bucket.connection.make_request(
            "GET", self.bucket.name, self.key_name, params=params)
        if response.status == 200:
            parts = []
            resp = load_data(response.read())
            for item in resp["object_parts"]:
                part = Part(self.bucket.name, self.key_name,
                            item["part_number"])
                part.size = item["size"]
                part.created = item["created"]
                parts.append(part)
            return parts
        else:

            err = get_response_error(response)