Exemplo n.º 1
0
def _upload_part(api, session, url, upload, part_number, part, retry_count,
                 timeout):
    """
    Used by the worker to upload a part to the storage service.
    :param api: Api instance.
    :param session: Storage service session.
    :param url: Part url.
    :param upload: Upload identifier.
    :param part_number: Part number.
    :param part: Part data.
    :param retry_count: Number of times to retry.
    :param timeout: Timeout for storage session.
    """
    part_url = retry(retry_count)(_get_part_url)(api, url, upload, part_number)

    e_tag = retry(retry_count)(_submit_part)(session, part_url, part, timeout)

    retry(retry_count)(_report_part)(api, url, upload, part_number, e_tag)
Exemplo n.º 2
0
 def _get_file_size(self):
     """
     Fetches file size by reading the Content-Length header
     for the resource.
     :return: File size.
     """
     file_size = retry(self._retry_count)(_get_content_length)(
         self._session, self.url, self._timeout)
     file_size = int(file_size)
     if file_size == 0:
         with io.open(self._temp_file, 'a', encoding='utf-8'):
             pass
     return file_size
Exemplo n.º 3
0
 def _get_file_size(self):
     """
     Fetches file size by reading the Content-Length header
     for the resource.
     :return: File size.
     """
     file_size = retry(self._retry_count)(_get_content_length)(
         self._session, self.url, self._timeout
     )
     file_size = int(file_size)
     if file_size == 0:
         with io.open(self._file_path, 'a', encoding='utf-8'):
             pass
     return file_size