Updates Dependencies, Creates Dockerfile and Formats Code
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
import os
|
||||
|
||||
|
||||
def get_allowed_origins():
|
||||
load_dotenv()
|
||||
@@ -11,4 +11,4 @@ def get_allowed_origins():
|
||||
if origins is None:
|
||||
return []
|
||||
|
||||
return origins.split(",")
|
||||
return origins.split(",")
|
||||
|
||||
@@ -4,7 +4,6 @@ from storage_service.controller.storage_controller import s3_router
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
|
||||
@@ -20,14 +20,16 @@ s3_router = InferringRouter()
|
||||
@cbv(s3_router)
|
||||
class StorageController:
|
||||
queue: Queue = Depends(dependency_queue, use_cache=True)
|
||||
storage_service: StorageService = Depends(dependency_storage_service, use_cache=True)
|
||||
storage_service: StorageService = Depends(
|
||||
dependency_storage_service, use_cache=True
|
||||
)
|
||||
|
||||
@s3_router.post("/new_file_url/", status_code=200)
|
||||
def new_file_url(
|
||||
self,
|
||||
username: Annotated[str, Body(embed=True)],
|
||||
file_postfix: Annotated[str, Body(embed=True)],
|
||||
file_type: Annotated[FileType, Body(embed=True)],
|
||||
self,
|
||||
username: Annotated[str, Body(embed=True)],
|
||||
file_postfix: Annotated[str, Body(embed=True)],
|
||||
file_type: Annotated[FileType, Body(embed=True)],
|
||||
) -> dict[str, str]:
|
||||
return self.storage_service.get_temp_upload_link(
|
||||
file_name_hash(username, file_postfix), file_type
|
||||
@@ -40,7 +42,9 @@ class StorageController:
|
||||
)
|
||||
|
||||
@s3_router.post("/process_file/", status_code=200)
|
||||
def process_file(self,
|
||||
username: Annotated[str, Body(embed=True)],
|
||||
file_postfix: Annotated[str, Body(embed=True)]):
|
||||
def process_file(
|
||||
self,
|
||||
username: Annotated[str, Body(embed=True)],
|
||||
file_postfix: Annotated[str, Body(embed=True)],
|
||||
):
|
||||
self.queue.enqueue(storage_file_worker, username, file_postfix)
|
||||
|
||||
@@ -5,7 +5,6 @@ from storage_service.utils.enums.file_type import FileType
|
||||
from storage_service.utils.file_handler import FILE_HANDLER
|
||||
|
||||
import boto3
|
||||
from PIL import Image
|
||||
|
||||
import io
|
||||
from typing import Any
|
||||
|
||||
@@ -6,6 +6,4 @@ from storage_service.utils.file_name_hash import file_name_hash
|
||||
|
||||
|
||||
def storage_file_worker(username: str, file_postfix: str) -> None:
|
||||
dependency_storage_service().process_file(
|
||||
file_name_hash(username, file_postfix)
|
||||
)
|
||||
dependency_storage_service().process_file(file_name_hash(username, file_postfix))
|
||||
|
||||
Reference in New Issue
Block a user