test:1
This commit is contained in:
+6
-7
@@ -50,6 +50,7 @@ class FileStorageInterface:
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class SystemFileStorage(FileStorageInterface):
|
||||
def __init__(self):
|
||||
self.chunk_size = 256 * 1024
|
||||
@@ -75,7 +76,7 @@ class SystemFileStorage(FileStorageInterface):
|
||||
|
||||
async def get_file_url(self, file_code: FileCodes):
|
||||
return await get_file_url(file_code.code)
|
||||
|
||||
|
||||
async def get_file_response(self, file_code: FileCodes):
|
||||
file_path = file_storage.root_path / await file_code.get_file_path()
|
||||
if not file_path.exists():
|
||||
@@ -89,9 +90,7 @@ class S3FileStorage(FileStorageInterface):
|
||||
self.secret_access_key = settings.s3_secret_access_key
|
||||
self.bucket_name = settings.s3_bucket_name
|
||||
self.endpoint_url = settings.s3_endpoint_url
|
||||
self.session = aioboto3.Session(
|
||||
aws_access_key_id=self.access_key_id, aws_secret_access_key=self.secret_access_key
|
||||
)
|
||||
self.session = aioboto3.Session(aws_access_key_id=self.access_key_id, aws_secret_access_key=self.secret_access_key)
|
||||
|
||||
async def save_file(self, file: UploadFile, save_path: str):
|
||||
async with self.session.client("s3", endpoint_url=self.endpoint_url) as s3:
|
||||
@@ -176,7 +175,6 @@ class OneDriveFileStorage(FileStorageInterface):
|
||||
else:
|
||||
raise e
|
||||
|
||||
|
||||
async def delete_file(self, file_code: FileCodes):
|
||||
await asyncio.to_thread(self._delete, await file_code.get_file_path())
|
||||
|
||||
@@ -200,6 +198,7 @@ class OneDriveFileStorage(FileStorageInterface):
|
||||
result = await asyncio.to_thread(self._get_file_url, await file_code.get_file_path(), f'{file_code.prefix}{file_code.suffix}')
|
||||
return result
|
||||
|
||||
|
||||
class OpenDALFileStorage(FileStorageInterface):
|
||||
def __init__(self):
|
||||
try:
|
||||
@@ -222,10 +221,10 @@ class OpenDALFileStorage(FileStorageInterface):
|
||||
|
||||
async def get_file_url(self, file_code: FileCodes):
|
||||
return await get_file_url(file_code.code)
|
||||
|
||||
|
||||
async def get_file_response(self, file_code: FileCodes):
|
||||
try:
|
||||
filename=file_code.prefix + file_code.suffix
|
||||
filename = file_code.prefix + file_code.suffix
|
||||
content = await self.operator.read(await file_code.get_file_path())
|
||||
headers = {
|
||||
"Content-Disposition": f'attachment; filename="{filename}"'
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
### Docker一键部署
|
||||
|
||||
#### 2.0版本,开发中
|
||||
|
||||
默认信息
|
||||
|
||||
后端地址:`/#/admin`
|
||||
@@ -37,6 +38,7 @@
|
||||
后台密码:`FileCodeBox2023`
|
||||
|
||||
AMD & ARM
|
||||
|
||||
```bash
|
||||
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:beta
|
||||
|
||||
@@ -82,13 +84,6 @@ docker logs filecodebox
|
||||
|
||||
仅供参考,历史版本->[部署文档](https://www.yuque.com/lxyo/work/zd0kvzy7fofx6w7v)
|
||||
|
||||
## 项目规划
|
||||
|
||||
2022年12月14日
|
||||
这个项目的灵感来源于丁丁快传,然后写了这么一个基于本机存储的快传系统,本系统主要是以轻量,单用户,离线环境(`私有化`
|
||||
)为主,因此也不需要加太多东西,所以其实这个项目到这基本功能已经完成了,剩下的就是维护和完善现有功能。
|
||||
也不会再加入新的大功能了,如果你有更好的想法和建议欢迎提issue。
|
||||
|
||||
## 预览
|
||||
|
||||
### 例站
|
||||
@@ -216,68 +211,6 @@ OSS_ENDPOINT=阿里云OSS Bucket的地域节点
|
||||
BUCKET_NAME=阿里云OSS Bucket的BucketName
|
||||
```
|
||||
|
||||
## 接口文档
|
||||
|
||||
前端比较简陋,可以使用接口进行二次开发
|
||||
|
||||
### 取件
|
||||
|
||||
#### PATH
|
||||
|
||||
`/`
|
||||
|
||||
#### METHOD
|
||||
|
||||
`POST`
|
||||
|
||||
#### PARAMS
|
||||
|
||||
code: 取件码
|
||||
|
||||
#### Response
|
||||
|
||||
```json
|
||||
{
|
||||
"detail": "msg",
|
||||
"data": {
|
||||
"type": "类型",
|
||||
"text": "文本",
|
||||
"name": "名称",
|
||||
"code": "取件码"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 寄件
|
||||
|
||||
#### PATH
|
||||
|
||||
`/share`
|
||||
|
||||
#### METHOD
|
||||
|
||||
`POST`
|
||||
|
||||
#### PARAMS
|
||||
|
||||
style: 1为次数,2为时间
|
||||
value: 次数或时间
|
||||
text: 取件码
|
||||
file: 文件
|
||||
|
||||
#### Response
|
||||
|
||||
```json
|
||||
{
|
||||
"detail": "msg",
|
||||
"data": {
|
||||
"code": "类型",
|
||||
"key": "唯一ID",
|
||||
"name": "名称"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 状态
|
||||
|
||||

|
||||
|
||||
Reference in New Issue
Block a user