Skip to content

Commit

Permalink
Use urlretrieve to download file in retrieve_files_from_article (cogn…
Browse files Browse the repository at this point in the history
  • Loading branch information
astrochun committed Dec 10, 2019
1 parent ce5771c commit 0534745
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions figshare/figshare.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import requests
from requests.exceptions import HTTPError
import os
from urllib.request import urlretrieve

def issue_request(method, url, headers, data=None, binary=False):
"""Wrapper for HTTP request
Expand Down Expand Up @@ -318,5 +319,4 @@ def retrieve_files_from_article(self, article_id, directory=None):
os.makedirs(dir0, exist_ok=True) # This might require Python >=3.2

for file_dict in file_list:
r = requests.get(file_dict['download_url']) #Will redirect
open(file_dict['name'], 'wb').write(r.content)
urlretrieve(file_dict['download_url'], os.path.join(dir0, file_dict['name']))

0 comments on commit 0534745

Please sign in to comment.