Skip to content

Commit

Permalink
feat: add initial upload endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
lchen-2101 committed Dec 11, 2023
1 parent 22a7e99 commit 5577472
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 47 deletions.
154 changes: 110 additions & 44 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ psycopg2-binary = "^2.9.9"
asyncpg = "^0.29.0"
regtech-api-commons = {git = "https://github.com/cfpb/regtech-api-commons.git"}
regtech-data-validator = {git = "https://github.com/cfpb/regtech-data-validator.git"}
python-multipart = "^0.0.6"
boto3 = "^1.33.12"

[tool.poetry.group.dev.dependencies]
pytest = "^7.4.3"
Expand Down
6 changes: 3 additions & 3 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from fastapi import FastAPI

from routers import filing_router

app = FastAPI()


@app.get("/test")
def test():
return "test"
app.include_router(filing_router, prefix="/v1/filing")
3 changes: 3 additions & 0 deletions src/routers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
__all__ = ["filing_router"]

from .filing import router as filing_router
15 changes: 15 additions & 0 deletions src/routers/filing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from http import HTTPStatus
from fastapi import Request, UploadFile, BackgroundTasks
from regtech_api_commons.api import Router
from services import submission_processor

router = Router()


@router.post("/{lei}/submissions/{submission_id}", status_code=HTTPStatus.ACCEPTED)
async def upload_file(
request: Request, lei: str, submission_id: str, file: UploadFile, background_tasks: BackgroundTasks
):
content = await file.read()
await submission_processor.upload_to_storage(lei, submission_id, content)
background_tasks.add_task(submission_processor.validate_submission, lei, submission_id, content)
Empty file added src/services/__init__.py
Empty file.
8 changes: 8 additions & 0 deletions src/services/submission_processor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
async def upload_to_storage(lei: str, submission_id: str, content: bytes):
# implement uploading process here
pass


async def validate_submission(lei: str, submission_id: str, content: bytes):
# implement validation process here
pass

0 comments on commit 5577472

Please sign in to comment.