mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-12 16:38:58 +08:00
refactor: remove the duplicate definitions across different modules (#9022)
This commit is contained in:
parent
4480b469a6
commit
959a81a41b
7
api/controllers/files/error.py
Normal file
7
api/controllers/files/error.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
from libs.exception import BaseHTTPException
|
||||||
|
|
||||||
|
|
||||||
|
class UnsupportedFileTypeError(BaseHTTPException):
|
||||||
|
error_code = "unsupported_file_type"
|
||||||
|
description = "File type not allowed."
|
||||||
|
code = 415
|
@ -4,7 +4,7 @@ from werkzeug.exceptions import NotFound
|
|||||||
|
|
||||||
import services
|
import services
|
||||||
from controllers.files import api
|
from controllers.files import api
|
||||||
from libs.exception import BaseHTTPException
|
from controllers.files.error import UnsupportedFileTypeError
|
||||||
from services.account_service import TenantService
|
from services.account_service import TenantService
|
||||||
from services.file_service import FileService
|
from services.file_service import FileService
|
||||||
|
|
||||||
@ -50,9 +50,3 @@ class WorkspaceWebappLogoApi(Resource):
|
|||||||
|
|
||||||
api.add_resource(ImagePreviewApi, "/files/<uuid:file_id>/image-preview")
|
api.add_resource(ImagePreviewApi, "/files/<uuid:file_id>/image-preview")
|
||||||
api.add_resource(WorkspaceWebappLogoApi, "/files/workspaces/<uuid:workspace_id>/webapp-logo")
|
api.add_resource(WorkspaceWebappLogoApi, "/files/workspaces/<uuid:workspace_id>/webapp-logo")
|
||||||
|
|
||||||
|
|
||||||
class UnsupportedFileTypeError(BaseHTTPException):
|
|
||||||
error_code = "unsupported_file_type"
|
|
||||||
description = "File type not allowed."
|
|
||||||
code = 415
|
|
||||||
|
@ -3,8 +3,8 @@ from flask_restful import Resource, reqparse
|
|||||||
from werkzeug.exceptions import Forbidden, NotFound
|
from werkzeug.exceptions import Forbidden, NotFound
|
||||||
|
|
||||||
from controllers.files import api
|
from controllers.files import api
|
||||||
|
from controllers.files.error import UnsupportedFileTypeError
|
||||||
from core.tools.tool_file_manager import ToolFileManager
|
from core.tools.tool_file_manager import ToolFileManager
|
||||||
from libs.exception import BaseHTTPException
|
|
||||||
|
|
||||||
|
|
||||||
class ToolFilePreviewApi(Resource):
|
class ToolFilePreviewApi(Resource):
|
||||||
@ -43,9 +43,3 @@ class ToolFilePreviewApi(Resource):
|
|||||||
|
|
||||||
|
|
||||||
api.add_resource(ToolFilePreviewApi, "/files/tools/<uuid:file_id>.<string:extension>")
|
api.add_resource(ToolFilePreviewApi, "/files/tools/<uuid:file_id>.<string:extension>")
|
||||||
|
|
||||||
|
|
||||||
class UnsupportedFileTypeError(BaseHTTPException):
|
|
||||||
error_code = "unsupported_file_type"
|
|
||||||
description = "File type not allowed."
|
|
||||||
code = 415
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user