add aliyun apis
This commit is contained in:
parent
1b6a06bd7b
commit
9948db8bce
@ -262,54 +262,70 @@ def list_path(path: str,
|
||||
|
||||
|
||||
@router.get("/aliyun/listdir", summary="所有目录(阿里云盘,不含文件)", response_model=List[schemas.FileItem])
|
||||
def list_dir(path: str, _: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
||||
def list_dir(path: str,
|
||||
fileid: str,
|
||||
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
||||
"""
|
||||
查询当前目录下所有目录
|
||||
"""
|
||||
if not path:
|
||||
if not fileid:
|
||||
return []
|
||||
if not path:
|
||||
path = "/"
|
||||
|
||||
|
||||
@router.get("/aliyun/mkdir", summary="创建目录(阿里云盘)", response_model=schemas.Response)
|
||||
def mkdir(path: str, _: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
||||
def mkdir(path: str,
|
||||
fileid: str,
|
||||
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
||||
"""
|
||||
创建目录
|
||||
"""
|
||||
if not path:
|
||||
if not fileid:
|
||||
return schemas.Response(success=False)
|
||||
if not path:
|
||||
path = "/"
|
||||
|
||||
|
||||
@router.get("/aliyun/delete", summary="删除文件或目录(阿里云盘)", response_model=schemas.Response)
|
||||
def delete(path: str, _: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
||||
def delete(path: str,
|
||||
fileid: str,
|
||||
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
||||
"""
|
||||
删除文件或目录
|
||||
"""
|
||||
if not path:
|
||||
if not fileid:
|
||||
return schemas.Response(success=False)
|
||||
if not path:
|
||||
path = "/"
|
||||
|
||||
|
||||
@router.get("/aliyun/download", summary="下载文件(阿里云盘)")
|
||||
def download(path: str, _: schemas.TokenPayload = Depends(verify_uri_token)) -> Any:
|
||||
def download(path: str,
|
||||
fileid: str,
|
||||
_: schemas.TokenPayload = Depends(verify_uri_token)) -> Any:
|
||||
"""
|
||||
下载文件或目录
|
||||
"""
|
||||
if not path:
|
||||
if not fileid:
|
||||
return schemas.Response(success=False)
|
||||
if not path:
|
||||
path = "/"
|
||||
|
||||
|
||||
@router.get("/aliyun/rename", summary="重命名文件或目录(阿里云盘)", response_model=schemas.Response)
|
||||
def rename(path: str, new_name: str, _: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
||||
def rename(fileid: str, new_name: str, _: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
||||
"""
|
||||
重命名文件或目录
|
||||
"""
|
||||
if not path or not new_name:
|
||||
if not fileid or not new_name:
|
||||
return schemas.Response(success=False)
|
||||
|
||||
|
||||
@router.get("/aliyun/image", summary="读取图片(阿里云盘)", response_model=schemas.Response)
|
||||
def image(path: str, _: schemas.TokenPayload = Depends(verify_uri_token)) -> Any:
|
||||
def image(fileid: str, _: schemas.TokenPayload = Depends(verify_uri_token)) -> Any:
|
||||
"""
|
||||
读取图片
|
||||
"""
|
||||
if not path:
|
||||
if not fileid:
|
||||
return schemas.Response(success=False)
|
||||
|
@ -1,10 +1,7 @@
|
||||
import base64
|
||||
import datetime
|
||||
import json
|
||||
import os
|
||||
import time
|
||||
import uuid
|
||||
from pathlib import Path
|
||||
from typing import Optional, Tuple, List
|
||||
|
||||
from requests import Response
|
||||
@ -44,8 +41,7 @@ class AliyunHelper:
|
||||
def __init__(self):
|
||||
self.systemconfig = SystemConfigOper()
|
||||
|
||||
@staticmethod
|
||||
def __log_error(res: Response, apiname: str):
|
||||
def __log_error(self, res: Response, apiname: str):
|
||||
"""
|
||||
统一处理和打印错误信息
|
||||
"""
|
||||
@ -56,7 +52,11 @@ class AliyunHelper:
|
||||
code = result.get("code")
|
||||
message = result.get("message")
|
||||
display_message = result.get("display_message")
|
||||
logger.warn(f"Aliyun {apiname}失败:{code} - {display_message or message}")
|
||||
if code or message:
|
||||
logger.warn(f"Aliyun {apiname}失败:{code} - {display_message or message}")
|
||||
if code == "DeviceSessionSignatureInvalid":
|
||||
logger.warn("设备会话签名无效,请重新扫码登录!")
|
||||
self.clear_params()
|
||||
|
||||
@property
|
||||
def auth_params(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user