Skip to content

Commit

Permalink
fix: Use requests to fetch event and speaker images (fossasia#6639)
Browse files Browse the repository at this point in the history
  • Loading branch information
codedsun committed Dec 22, 2019
1 parent 6e7bc10 commit 5e13811
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
12 changes: 10 additions & 2 deletions 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 Expand Up @@ -129,7 +130,14 @@ def create_save_image_sizes(image_file, image_sizes_type, unique_identifier=None
try:
image_sizes = ImageSizes.query.filter_by(type=image_sizes_type).one()
except NoResultFound:
image_sizes = ImageSizes(image_sizes_type, 1300, 500, True, 100, 75, 30, True, 100, 500, 200, True, 100)
image_sizes = ImageSizes(image_sizes_type, full_width=1300,
full_height=500, full_aspect=True, full_quality=80,
icon_width=75, icon_height=30, icon_aspect=True,
icon_quality=80, thumbnail_width=500, thumbnail_height=200,
thumbnail_aspect=True, thumbnail_quality=80, logo_width=500,
logo_height=200, icon_size_width_height=35, icon_size_quality=80,
small_size_width_height=50, small_size_quality=80,
thumbnail_size_width_height=500)

# Get an unique identifier from uuid if not provided
if unique_identifier is None:
Expand Down
9 changes: 3 additions & 6 deletions docs/api/blueprint/user/users.apib
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ Create a new user using an email, password and an optional name.
{
"email": "email@example.com",
"password": "password",
"avatar_url": "http://example.com/example.png",
"avatar_url": "https://avatars2.githubusercontent.com/u/1583873",
"first-name": "John",
"last-name": "Doe",
"details": "example",
Expand Down Expand Up @@ -550,18 +550,15 @@ Authorized user should be same as user in request body or must be admin.
"data": {
"attributes": {
"password": "password",
"avatar_url": "http://example.com/example.png",
"avatar_url": "https://avatars2.githubusercontent.com/u/1583873",
"first-name": "John",
"last-name": "Doe",
"details": "example1",
"contact": "example1",
"facebook-url": "http://facebook.com/facebook",
"twitter-url": "http://twitter.com/twitter",
"instagram-url": "http://instagram.com/instagram",
"google-plus-url": "http://plus.google.com/plus.google",
"thumbnail-image-url": "http://example.com/example.png",
"small-image-url": "http://example.com/example.png",
"icon-image-url": "http://example.com/example.png"
"google-plus-url": "http://plus.google.com/plus.google"
},
"type": "user",
"id": "2"
Expand Down

0 comments on commit 5e13811

Please sign in to comment.