Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
seljin authored Sep 9, 2020
2 parents c66e7c5 + 2423bd5 commit ad4882a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions rest_models/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@ def _save(self, name, content):
content.name = content.original_name = name
return content

def size(self, name):
cursor = self.get_cursor(name) # fetch a valid cursor which just got the name
url = self.url(name)
# try with anonymous data
response = get_basic_session().get(url, stream=True)
# if we fail, we try with authenticated session
if response.status_code in (403, 401):
response = cursor.session.get(url, stream=True)

return response.headers['Content-length']

def get_cursor(self, name):
return self.result_file_pool[name][1] # pool contains url and cursor to get it

Expand Down

0 comments on commit ad4882a

Please sign in to comment.