chore error status code and custom provider name
This commit is contained in:
@@ -65,7 +65,7 @@ export default function S3Configs({}: {}) {
|
||||
{
|
||||
label: "Custom Provider",
|
||||
value: "Custom Provider",
|
||||
platform: "custom",
|
||||
platform: "custom provider",
|
||||
channel: "cp",
|
||||
},
|
||||
];
|
||||
|
||||
@@ -28,14 +28,12 @@ export async function POST(request: NextRequest) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: false,
|
||||
error: `缺少必需字段: ${missingFields.join(", ")}`,
|
||||
error: `Missing required fields: ${missingFields.join(", ")}`,
|
||||
},
|
||||
{ status: 400 },
|
||||
);
|
||||
}
|
||||
|
||||
console.log(body);
|
||||
|
||||
const userFile = await createUserFile({
|
||||
userId: body.userId,
|
||||
name: body.name,
|
||||
|
||||
@@ -48,17 +48,17 @@ export async function POST(request: NextRequest) {
|
||||
for (const file of files) {
|
||||
if (Number(file.size) > Number(plan.stMaxFileSize)) {
|
||||
return Response.json(`File (${file.name}) size limit exceeded`, {
|
||||
status: 403,
|
||||
status: 400,
|
||||
});
|
||||
}
|
||||
}
|
||||
const limit = await restrictByTimeRange({
|
||||
model: "userFile",
|
||||
userId: user.id,
|
||||
limit: Number(plan.stMaxFileCount),
|
||||
rangeType: "month",
|
||||
});
|
||||
if (limit) return Response.json(limit.statusText, { status: limit.status });
|
||||
// const limit = await restrictByTimeRange({
|
||||
// model: "userFile",
|
||||
// userId: user.id,
|
||||
// limit: Number(plan.stMaxFileCount),
|
||||
// rangeType: "month",
|
||||
// });
|
||||
// if (limit) return Response.json(limit.statusText, { status: limit.status });
|
||||
|
||||
const R2 = createS3Client(
|
||||
providerChannel.endpoint,
|
||||
|
||||
+3
-1
@@ -159,8 +159,10 @@ export async function getUserFiles(options: QueryUserFileOptions = {}) {
|
||||
prisma.userFile.count({ where }),
|
||||
prisma.userFile.aggregate({
|
||||
where: {
|
||||
...(userId && { userId }),
|
||||
// bucket,
|
||||
// providerName,
|
||||
status: 1,
|
||||
...(userId && { userId }),
|
||||
},
|
||||
_sum: { size: true },
|
||||
}),
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user