def upload_document()

in backend-printing/helper/universal_print_client.py [0:0]


    def upload_document(self, request_body: dict):
        """Upload the document to the Universal Print.

        Args:
            file_path (str): file path

        Returns:
            dict: response
        """
        try:
            range = [
                int(num)
                for num in re.findall(r"\d+", request_body["next_expected_range"])
            ]
            blob_data = base64.b64decode(request_body["document_blob"])
            content_range = f"bytes 0-{len(blob_data) - 1}/{len(blob_data)}"
            headers = {
                "Content-Type": "application/json",
                "Content-Range": content_range,
                "Content-Length": str(len(blob_data)),
                "Accept": "*/*",
            }
            response = requests.put(
                url=request_body["upload_url"], headers=headers, data=blob_data
            )
            return response
        except Exception as e:
            raise Exception(
                f"Exception occurred while uploading the document to the UP URL: {e}"
            )