This commit is contained in:
张成
2025-11-26 12:39:21 +08:00
parent 5d59000960
commit 7858459118
12 changed files with 1785 additions and 2 deletions

View File

@@ -1,7 +1,91 @@
const Framework = require("../../framework/node-core-framework.js");
const ossToolService = require('../services/oss_tool_service.js');
module.exports = {
module.exports = {
/**
* @swagger
* /api/file/upload_oss:
* post:
* summary: 上传文件到OSS
* description: 将Base64编码的文件上传到阿里云OSS
* tags: [前端-文件管理]
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* required:
* - fileBase64
* properties:
* fileBase64:
* type: string
* format: base64
* description: Base64编码的文件内容
* example: '/9j/4AAQSkZJRgABAQEAYABgAAD...'
* responses:
* 200:
* description: 上传成功
* content:
* application/json:
* schema:
* type: object
* properties:
* code:
* type: integer
* description: 状态码0表示成功
* example: 0
* message:
* type: string
* description: 响应消息
* example: 'success'
* data:
* type: object
* properties:
* success:
* type: boolean
* description: 是否成功
* example: true
* name:
* type: string
* description: OSS文件名称
* path:
* type: string
* description: OSS文件URL
* ossPath:
* type: string
* description: OSS完整路径
* fileType:
* type: string
* description: 文件类型
* fileSize:
* type: integer
* description: 文件大小(字节)
* originalName:
* type: string
* description: 原始文件名
* suffix:
* type: string
* description: 文件后缀
* storagePath:
* type: string
* description: 存储路径
* 400:
* description: 参数错误
* content:
* application/json:
* schema:
* type: object
* properties:
* code:
* type: integer
* example: 400
* message:
* type: string
* example: '缺少必要参数fileBase64'
* 500:
* description: 服务器错误或上传失败
*/
'POST /file/upload_oss': async (ctx) => {
const body = ctx.getBody();
const { fileBase64 } = body;