-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: export dataset * remove file buffer
- Loading branch information
Showing
3 changed files
with
23 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 16 additions & 26 deletions
42
projects/app/src/pages/api/support/user/team/limit/exportDatasetLimit.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,24 @@ | ||
import type { NextApiRequest, NextApiResponse } from 'next'; | ||
import { jsonRes } from '@fastgpt/service/common/response'; | ||
import { connectToDatabase } from '@/service/mongo'; | ||
import { authDataset } from '@fastgpt/service/support/permission/auth/dataset'; | ||
import { checkExportDatasetLimit } from '@fastgpt/service/support/user/utils'; | ||
import { NextAPI } from '@/service/middle/entry'; | ||
|
||
export default async function handler(req: NextApiRequest, res: NextApiResponse<any>) { | ||
try { | ||
await connectToDatabase(); | ||
const { datasetId } = req.query as { | ||
datasetId: string; | ||
}; | ||
async function handler(req: NextApiRequest, res: NextApiResponse<any>) { | ||
const { datasetId } = req.query as { | ||
datasetId: string; | ||
}; | ||
|
||
if (!datasetId) { | ||
throw new Error('datasetId is required'); | ||
} | ||
|
||
// 凭证校验 | ||
const { teamId } = await authDataset({ req, authToken: true, datasetId, per: 'w' }); | ||
if (!datasetId) { | ||
throw new Error('datasetId is required'); | ||
} | ||
|
||
await checkExportDatasetLimit({ | ||
teamId, | ||
limitMinutes: global.feConfigs?.limit?.exportDatasetLimitMinutes | ||
}); | ||
// 凭证校验 | ||
const { teamId } = await authDataset({ req, authToken: true, datasetId, per: 'w' }); | ||
|
||
jsonRes(res); | ||
} catch (err) { | ||
res.status(500); | ||
jsonRes(res, { | ||
code: 500, | ||
error: err | ||
}); | ||
} | ||
await checkExportDatasetLimit({ | ||
teamId, | ||
limitMinutes: global.feConfigs?.limit?.exportDatasetLimitMinutes | ||
}); | ||
} | ||
|
||
export default NextAPI(handler); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters