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