Пример #1
0
 def download(self, download_range=None):
     """
     Download file contents.
     Returns a FileDownload.
     Optional range is 2 integer sequence (start offset, end offset) used to download only part of the file.
     """
     url = self._client.get_url(self._url_template_content, path=self.path)
     if download_range is None:
         r = exc.default.check_response(self._client.GET(url, stream=True))
     else:
         if len(download_range) != 2:
             raise exc.InvalidParameters('Download range needs to be None or a 2 element integer sequence')
         r = exc.partial.check_response(self._client.GET(url, stream=True, headers={'Range': 'bytes=%d-%d' % download_range}))
     return base.FileDownload(r, self)
Пример #2
0
 def download(self):
     r = self._client.GET(self.complete_url(), stream=True)
     exc.default.check_response(r)
     return base.FileDownload(r, None)