Skip to content

Commit

Permalink
fix: Image resizing performed using requests library
Browse files Browse the repository at this point in the history
  • Loading branch information
codedsun committed Dec 5, 2019
1 parent 6d098cb commit 668dcb9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
3 changes: 2 additions & 1 deletion app/api/helpers/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import urllib.parse
import urllib.request
import uuid
import requests

import PIL
from PIL import Image
Expand Down Expand Up @@ -77,7 +78,7 @@ def create_save_resized_image(image_file, basewidth=None, maintain_aspect=None,
if not image_file:
return None
filename = '{filename}.{ext}'.format(filename=get_file_name(), ext=ext)
data = urllib.request.urlopen(image_file).read()
data = requests.get(image_file).content
image_file = io.BytesIO(data)
try:
im = Image.open(image_file)
Expand Down
14 changes: 4 additions & 10 deletions tests/hook_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def skip_token_refresh(transaction):

# ------------------------- Users -------------------------
@hooks.before("Users > Users Collection > List All Users")
def user_get_list(transaction):
def skip_user_get_list(transaction):
"""
GET /users
:param transaction:
Expand All @@ -176,10 +176,7 @@ def user_post(transaction):
:param transaction:
:return:
"""
with stash['app'].app_context():
user = UserFactory()
db.session.add(user)
db.session.commit()
transaction['skip'] = True


@hooks.before("Users > User Details > Get Details")
Expand All @@ -196,16 +193,13 @@ def user_get_detail(transaction):


@hooks.before("Users > User Details > Update User")
def user_patch(transaction):
def skip_user_patch(transaction):
"""
PATCH /users/2
:param transaction:
:return:
"""
with stash['app'].app_context():
user = UserFactory()
db.session.add(user)
db.session.commit()
transaction['skip'] = True


@hooks.before("Users > User Details > Delete User")
Expand Down

0 comments on commit 668dcb9

Please sign in to comment.