Skip to content

Commit

Permalink
[#16] Fix Process Image functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dedenbangkit committed Sep 12, 2023
1 parent 46b1681 commit b5adfa7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion backend/akvo/core_storage/functions.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from os import environ
from os import environ, path, mkdir
from uuid import uuid4
from akvo.utils import storage

storage = storage.Storage(storage_path=environ.get("STORAGE_PATH"))


def generate_image_file(file, filename, folder="images"):
# create a temporary folder to store the file
if not path.exists("./tmp"):
mkdir("./tmp")
temp_file = open(f"./tmp/{filename}", "wb+")
for chunk in file.chunks():
temp_file.write(chunk)
Expand Down
1 change: 1 addition & 0 deletions backend/akvo/core_storage/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from akvo.utils import storage

STORAGE_PATH = os.environ.get("STORAGE_PATH")
storage = storage.Storage(storage_path=STORAGE_PATH)


def generate_image(filename: str, extension: str = "jpg"):
Expand Down

0 comments on commit b5adfa7

Please sign in to comment.