-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wasabi S3 integration for fetching .osu files (#9)
* Wasabi S3 integration for .osu files * add env example
- Loading branch information
Showing
8 changed files
with
81 additions
and
6 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
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,37 @@ | ||
import logging | ||
|
||
from app import settings | ||
from app import state | ||
|
||
|
||
async def get_object_data(key: str) -> bytes | None: | ||
try: | ||
s3_object = await state.s3_client.get_object( | ||
Bucket=settings.AWS_S3_BUCKET_NAME, | ||
Key=key, | ||
) | ||
except Exception: | ||
logging.warning( | ||
"Failed to get object data from S3", | ||
exc_info=True, | ||
extra={"object_key": key}, | ||
) | ||
return None | ||
|
||
return await s3_object["Body"].read() | ||
|
||
|
||
async def save_object_data(key: str, data: bytes) -> None: | ||
try: | ||
await state.s3_client.put_object( | ||
Bucket=settings.AWS_S3_BUCKET_NAME, | ||
Key=key, | ||
Body=data, | ||
) | ||
except Exception: | ||
logging.warning( | ||
"Failed to save object data to S3", | ||
exc_info=True, | ||
extra={"object_key": key}, | ||
) | ||
return 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
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
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
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 |
---|---|---|
@@ -1,3 +1,8 @@ | ||
from databases import Database | ||
from typing import TYPE_CHECKING | ||
|
||
database: Database | ||
if TYPE_CHECKING: | ||
from databases import Database | ||
from types_aiobotocore_s3.client import S3Client | ||
|
||
database: "Database" | ||
s3_client: "S3Client" |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
mypy | ||
types-aiobotocore[s3] | ||
types-jmespath | ||
types-pyyaml |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
aiobotocore | ||
cryptography | ||
databases[aiomysql] | ||
fastapi | ||
|