Skip to content

Commit

Permalink
fix/thumbnails-proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
joelclems committed Jun 18, 2021
1 parent f69cd87 commit 4fb30f4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
14 changes: 13 additions & 1 deletion apptax/taxonomie/filemanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,23 @@ def url_to_image(url):
"""
Récupération d'une image à partir d'une url
"""
r = requests.get(url, stream=True)

r = requests.get(
url,
stream=True,
proxies={
"http": current_app.config.get('HTTP_PROXY'),
"https": current_app.config.get('HTTPS_PROXY')
}
)

if (r.status_code >=400):
raise Exception("Pb with request : status code {}".format(r.status_code))
try:
img = Image.open(io.BytesIO(r.content))
except IOError:
raise Exception("Media is not an image")

return img


Expand Down
4 changes: 4 additions & 0 deletions config.py.sample
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ PASS_METHOD='hash'
# ID APPLICATION TaxHub
# User in the authentification submodule to avoid token conflict between app on the same server
ID_APP = 2

# PROXIES
HTTP_PROXY = None
HTTPS_PROXY = None

0 comments on commit 4fb30f4

Please sign in to comment.