# Path: google/resumable_media/_upload.py
# _CONTENT_TYPE_HEADER = "content-type"
# _CONTENT_RANGE_TEMPLATE = "bytes {:d}-{:d}/{:d}"
# _RANGE_UNKNOWN_TEMPLATE = "bytes {:d}-{:d}/*"
# _EMPTY_RANGE_TEMPLATE = "bytes */{:d}"
# _BOUNDARY_WIDTH = len(str(sys.maxsize - 1))
# _BOUNDARY_FORMAT = "==============={{:0{:d}d}}==".format(_BOUNDARY_WIDTH)
# _MULTIPART_SEP = b"--"
# _CRLF = b"\r\n"
# _MULTIPART_BEGIN = b"\r\ncontent-type: application/json; charset=UTF-8\r\n\r\n"
# _RELATED_HEADER = b'multipart/related; boundary="'
# _BYTES_RANGE_RE = re.compile(r"bytes=0-(?P<end_byte>\d+)", flags=re.IGNORECASE)
# _STREAM_ERROR_TEMPLATE = (
#     "Bytes stream is in unexpected state. "
#     "The local stream has had {:d} bytes read from it while "
#     "{:d} bytes have already been updated (they should match)."
# )
# _STREAM_READ_PAST_TEMPLATE = (
#     "{:d} bytes have been read from the stream, which exceeds "
#     "the expected total {:d}."
# )
# _POST = "POST"
# _PUT = "PUT"
# _UPLOAD_CHECKSUM_MISMATCH_MESSAGE = (
#     "The computed ``{}`` checksum, ``{}``, and the checksum reported by the "
#     "remote host, ``{}``, did not match."
# )
# _UPLOAD_METADATA_NO_APPROPRIATE_CHECKSUM_MESSAGE = (
#     "Response metadata had no ``{}`` value; checksum could not be validated."
# )
# class UploadBase(object):
# class SimpleUpload(UploadBase):
# class MultipartUpload(UploadBase):
# class ResumableUpload(UploadBase):
#     def __init__(self, upload_url, headers=None):
#     def finished(self):
#     def _process_response(self, response):
#     def _get_status_code(response):
#     def _get_headers(response):
#     def _get_body(response):
#     def _prepare_request(self, data, content_type):
#     def transmit(self, transport, data, content_type, timeout=None):
#     def __init__(self, upload_url, headers=None, checksum=None):
#     def _prepare_request(self, data, metadata, content_type):
#     def transmit(self, transport, data, metadata, content_type, timeout=None):
#     def __init__(self, upload_url, chunk_size, checksum=None, headers=None):
#     def invalid(self):
#     def chunk_size(self):
#     def resumable_url(self):
#     def bytes_uploaded(self):
#     def total_bytes(self):
#     def _prepare_initiate_request(
#         self, stream, metadata, content_type, total_bytes=None, stream_final=True
#     ):
#     def _process_initiate_response(self, response):
#     def initiate(
#         self,
#         transport,
#         stream,
#         metadata,
#         content_type,
#         total_bytes=None,
#         stream_final=True,
#         timeout=None,
#     ):
#     def _prepare_request(self):
#     def _update_checksum(self, start_byte, payload):
#     def _make_invalid(self):
#     def _process_resumable_response(self, response, bytes_sent):
#     def _validate_checksum(self, response):
#     def transmit_next_chunk(self, transport, timeout=None):
#     def _prepare_recover_request(self):
#     def _process_recover_response(self, response):
#     def recover(self, transport):
# def get_boundary():
# def construct_multipart_request(data, metadata, content_type):
# def get_total_bytes(stream):
# def get_next_chunk(stream, chunk_size, total_bytes):
# def get_content_range(start_byte, end_byte, total_bytes):
# 
# Path: google/resumable_media/requests/_request_helpers.py
# _DEFAULT_RETRY_STRATEGY = common.RetryStrategy()
# _SINGLE_GET_CHUNK_SIZE = 8192
# _DEFAULT_CONNECT_TIMEOUT = 61
# _DEFAULT_READ_TIMEOUT = 60
# _CONNECTION_ERROR_CLASSES = (
#     requests.exceptions.ConnectionError,
#     requests.exceptions.ChunkedEncodingError,
#     urllib3.exceptions.ProtocolError,
#     ConnectionError,  # Python 3.x only, superclass of ConnectionResetError.
# )
# class RequestsMixin(object):
# class RawRequestsMixin(RequestsMixin):
#     def _get_status_code(response):
#     def _get_headers(response):
#     def _get_body(response):
#     def _get_body(response):
# def wait_and_retry(func, get_status_code, retry_strategy):


from google.resumable_media import _upload
from google.resumable_media.requests import _request_helpers
            content_type (str): The content type of the resource, e.g. a JPEG
                image has content type ``image/jpeg``.
            timeout (Optional[Union[float, Tuple[float, float]]]):
                The number of seconds to wait for the server response.
                Depending on the retry strategy, a request may be repeated
                several times using the same timeout each time.

                Can also be passed as a tuple (connect_timeout, read_timeout).
                See :meth:`requests.Session.request` documentation for details.

        Returns:
            ~requests.Response: The HTTP response returned by ``transport``.
        """
        method, url, payload, headers = self._prepare_request(data, content_type)

        # Wrap the request business logic in a function to be retried.
        def retriable_request():
            result = transport.request(
                method, url, data=payload, headers=headers, timeout=timeout
            )

            self._process_response(result)

            return result

        return _request_helpers.wait_and_retry(
            retriable_request, self._get_status_code, self._retry_strategy
        )



# Path: google/resumable_media/_upload.py
# _CONTENT_TYPE_HEADER = "content-type"
# _CONTENT_RANGE_TEMPLATE = "bytes {:d}-{:d}/{:d}"
# _RANGE_UNKNOWN_TEMPLATE = "bytes {:d}-{:d}/*"
# _EMPTY_RANGE_TEMPLATE = "bytes */{:d}"
# _BOUNDARY_WIDTH = len(str(sys.maxsize - 1))
# _BOUNDARY_FORMAT = "==============={{:0{:d}d}}==".format(_BOUNDARY_WIDTH)
# _MULTIPART_SEP = b"--"
# _CRLF = b"\r\n"
# _MULTIPART_BEGIN = b"\r\ncontent-type: application/json; charset=UTF-8\r\n\r\n"
# _RELATED_HEADER = b'multipart/related; boundary="'
# _BYTES_RANGE_RE = re.compile(r"bytes=0-(?P<end_byte>\d+)", flags=re.IGNORECASE)
# _STREAM_ERROR_TEMPLATE = (
#     "Bytes stream is in unexpected state. "
#     "The local stream has had {:d} bytes read from it while "
#     "{:d} bytes have already been updated (they should match)."
# )
# _STREAM_READ_PAST_TEMPLATE = (
#     "{:d} bytes have been read from the stream, which exceeds "
#     "the expected total {:d}."
# )
# _POST = "POST"
# _PUT = "PUT"
# _UPLOAD_CHECKSUM_MISMATCH_MESSAGE = (
#     "The computed ``{}`` checksum, ``{}``, and the checksum reported by the "
#     "remote host, ``{}``, did not match."
# )
# _UPLOAD_METADATA_NO_APPROPRIATE_CHECKSUM_MESSAGE = (
#     "Response metadata had no ``{}`` value; checksum could not be validated."
# )
# class UploadBase(object):
# class SimpleUpload(UploadBase):
# class MultipartUpload(UploadBase):
# class ResumableUpload(UploadBase):
#     def __init__(self, upload_url, headers=None):
#     def finished(self):
#     def _process_response(self, response):
#     def _get_status_code(response):
#     def _get_headers(response):
#     def _get_body(response):
#     def _prepare_request(self, data, content_type):
#     def transmit(self, transport, data, content_type, timeout=None):
#     def __init__(self, upload_url, headers=None, checksum=None):
#     def _prepare_request(self, data, metadata, content_type):
#     def transmit(self, transport, data, metadata, content_type, timeout=None):
#     def __init__(self, upload_url, chunk_size, checksum=None, headers=None):
#     def invalid(self):
#     def chunk_size(self):
#     def resumable_url(self):
#     def bytes_uploaded(self):
#     def total_bytes(self):
#     def _prepare_initiate_request(
#         self, stream, metadata, content_type, total_bytes=None, stream_final=True
#     ):
#     def _process_initiate_response(self, response):
#     def initiate(
#         self,
#         transport,
#         stream,
#         metadata,
#         content_type,
#         total_bytes=None,
#         stream_final=True,
#         timeout=None,
#     ):
#     def _prepare_request(self):
#     def _update_checksum(self, start_byte, payload):
#     def _make_invalid(self):
#     def _process_resumable_response(self, response, bytes_sent):
#     def _validate_checksum(self, response):
#     def transmit_next_chunk(self, transport, timeout=None):
#     def _prepare_recover_request(self):
#     def _process_recover_response(self, response):
#     def recover(self, transport):
# def get_boundary():
# def construct_multipart_request(data, metadata, content_type):
# def get_total_bytes(stream):
# def get_next_chunk(stream, chunk_size, total_bytes):
# def get_content_range(start_byte, end_byte, total_bytes):
# 
# Path: google/resumable_media/requests/_request_helpers.py
# _DEFAULT_RETRY_STRATEGY = common.RetryStrategy()
# _SINGLE_GET_CHUNK_SIZE = 8192
# _DEFAULT_CONNECT_TIMEOUT = 61
# _DEFAULT_READ_TIMEOUT = 60
# _CONNECTION_ERROR_CLASSES = (
#     requests.exceptions.ConnectionError,
#     requests.exceptions.ChunkedEncodingError,
#     urllib3.exceptions.ProtocolError,
#     ConnectionError,  # Python 3.x only, superclass of ConnectionResetError.
# )
# class RequestsMixin(object):
# class RawRequestsMixin(RequestsMixin):
#     def _get_status_code(response):
#     def _get_headers(response):
#     def _get_body(response):
#     def _get_body(response):
# def wait_and_retry(func, get_status_code, retry_strategy):


# Path: google/resumable_media/requests/upload.py
from google.resumable_media import _upload
from google.resumable_media.requests import _request_helpers

            content_type (str): The content type of the resource, e.g. a JPEG
                image has content type ``image/jpeg``.
            timeout (Optional[Union[float, Tuple[float, float]]]):
                The number of seconds to wait for the server response.
                Depending on the retry strategy, a request may be repeated
                several times using the same timeout each time.

                Can also be passed as a tuple (connect_timeout, read_timeout).
                See :meth:`requests.Session.request` documentation for details.

        Returns:
            ~requests.Response: The HTTP response returned by ``transport``.
        """
        method, url, payload, headers = self._prepare_request(data, content_type)

        # Wrap the request business logic in a function to be retried.
        def retriable_request():
            result = transport.request(
                method, url, data=payload, headers=headers, timeout=timeout
            )

            self._process_response(result)

            return result

        return _request_helpers.wait_and_retry(
            retriable_request, self._get_status_code, self._retry_strategy
        )



class MultipartUpload(_request_helpers.RequestsMixin, _upload.MultipartUpload):