Skip to content

Commit

Permalink
update:存储
Browse files Browse the repository at this point in the history
  • Loading branch information
vastsa committed Aug 15, 2023
1 parent 5e9768c commit a4d85bc
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
9 changes: 9 additions & 0 deletions core/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# @Time : 2023/8/15 09:51
# @Author : Lan
# @File : settings.py
# @Software: PyCharm
from pathlib import Path

data_root = Path('./data')
if not data_root.exists():
data_root.mkdir(parents=True, exist_ok=True)
5 changes: 2 additions & 3 deletions core/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@

import aioboto3
from fastapi import UploadFile
from pathlib import Path

from core.settings import data_root
from apps.base.models import FileCodes


class SystemFileStorage:
def __init__(self):
self.chunk_size = 256 * 1024
self.root_path = Path('./data')
self.root_path = data_root
self.token = '123456'

def _save(self, file, save_path):
Expand Down
Binary file removed filecodebox.db-shm
Binary file not shown.
Empty file removed filecodebox.db-wal
Empty file.
5 changes: 2 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@
from tortoise.contrib.fastapi import register_tortoise
from apps.base.views import share_api
from apps.admin.views import admin_api
from core.settings import data_root

app = FastAPI()

app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)

app.mount('/assets', StaticFiles(directory='./fcb-fronted/dist/assets'), name="assets")

register_tortoise(
Expand All @@ -28,7 +27,7 @@
add_exception_handlers=True,
config={
'connections': {
'default': 'sqlite://filecodebox.db'
'default': f'sqlite://{data_root}/filecodebox.db'
},
'apps': {
'models': {
Expand Down

0 comments on commit a4d85bc

Please sign in to comment.