|
@@ -9,19 +9,19 @@ import { parseWithAwait } from '@/server/utils/parseWithAwait';
|
|
|
|
|
|
|
|
|
|
|
|
|
const CreateFileResponseSchema = z.object({
|
|
const CreateFileResponseSchema = z.object({
|
|
|
- file: FileSchema,
|
|
|
|
|
- uploadPolicy: z.object({
|
|
|
|
|
- 'x-amz-algorithm': z.string(),
|
|
|
|
|
- 'x-amz-credential': z.string(),
|
|
|
|
|
- 'x-amz-date': z.string(),
|
|
|
|
|
- 'x-amz-security-token': z.string().optional(),
|
|
|
|
|
- policy: z.string(),
|
|
|
|
|
- 'x-amz-signature': z.string(),
|
|
|
|
|
- host: z.string(),
|
|
|
|
|
- key: z.string(),
|
|
|
|
|
- bucket: z.string()
|
|
|
|
|
- })
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ file: FileSchema,
|
|
|
|
|
+ uploadPolicy: z.object({
|
|
|
|
|
+ 'x-amz-algorithm': z.string(),
|
|
|
|
|
+ 'x-amz-credential': z.string(),
|
|
|
|
|
+ 'x-amz-date': z.string(),
|
|
|
|
|
+ 'x-amz-security-token': z.string().optional(),
|
|
|
|
|
+ policy: z.string(),
|
|
|
|
|
+ 'x-amz-signature': z.string(),
|
|
|
|
|
+ host: z.string(),
|
|
|
|
|
+ key: z.string(),
|
|
|
|
|
+ bucket: z.string()
|
|
|
|
|
+ })
|
|
|
|
|
+});
|
|
|
|
|
|
|
|
// 创建文件上传策略路由
|
|
// 创建文件上传策略路由
|
|
|
const createUploadPolicyRoute = createRoute({
|
|
const createUploadPolicyRoute = createRoute({
|
|
@@ -61,10 +61,10 @@ const app = new OpenAPIHono<AuthContext>().openapi(createUploadPolicyRoute, asyn
|
|
|
try {
|
|
try {
|
|
|
const data = await c.req.json();
|
|
const data = await c.req.json();
|
|
|
const user = c.get('user');
|
|
const user = c.get('user');
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 创建文件服务实例
|
|
// 创建文件服务实例
|
|
|
const fileService = new FileService(AppDataSource);
|
|
const fileService = new FileService(AppDataSource);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 添加用户ID到文件数据
|
|
// 添加用户ID到文件数据
|
|
|
const fileData = {
|
|
const fileData = {
|
|
|
...data,
|
|
...data,
|