upload_1.py 785 B

1234567891011121314151617181920212223
  1. def transmit(self, transport, data, content_type):
  2. """Transmit the resource to be uploaded.
  3. Args:
  4. transport (~requests.Session): A ``requests`` object which can
  5. make authenticated requests.
  6. data (bytes): The resource content to be uploaded.
  7. content_type (str): The content type of the resource, e.g. a JPEG
  8. image has content type ``image/jpeg``.
  9. Returns:
  10. ~requests.Response: The HTTP response returned by ``transport``.
  11. """
  12. method, url, payload, headers = self._prepare_request(
  13. data, content_type)
  14. result = _helpers.http_request(
  15. transport, method, url, data=payload, headers=headers,
  16. retry_strategy=self._retry_strategy)
  17. self._process_response(result)
  18. return result