-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: upload image to imgur to reduce slug size
heroku limit: the maximum slug size is 500 MB
- Loading branch information
Showing
5 changed files
with
19 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ MerchantID= | |
HashKey= | ||
HashIV= | ||
PORT= | ||
IMGUR_ID= |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from helpers.products_view_helper.upload_to_imgur import upload_to_imgur |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import os | ||
from typing import Union | ||
from flask_imgur.flask_imgur import Imgur | ||
|
||
imgur_handler = Imgur(client_id=os.environ.get('IMGUR_ID')) | ||
|
||
|
||
def upload_to_imgur(image: bytes) -> Union[str, None]: | ||
if not image: | ||
return None | ||
|
||
image_data = imgur_handler.send_image(image) | ||
return image_data['data']['link'] if image_data['success'] else None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters