Updates to handle video in a dataset on ui
This commit is contained in:
@@ -6,7 +6,10 @@ import { getDatasetsRoot } from '@/server/settings';
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
const body = await request.json();
|
||||
const { name } = body;
|
||||
let { name } = body;
|
||||
// clean name by making lower case, removing special characters, and replacing spaces with underscores
|
||||
name = name.toLowerCase().replace(/[^a-z0-9]+/g, '_');
|
||||
|
||||
let datasetsPath = await getDatasetsRoot();
|
||||
let datasetPath = path.join(datasetsPath, name);
|
||||
|
||||
@@ -15,7 +18,7 @@ export async function POST(request: Request) {
|
||||
fs.mkdirSync(datasetPath);
|
||||
}
|
||||
|
||||
return NextResponse.json({ success: true });
|
||||
return NextResponse.json({ success: true, name: name });
|
||||
} catch (error) {
|
||||
return NextResponse.json({ error: 'Failed to create dataset' }, { status: 500 });
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ export async function POST(request: Request) {
|
||||
* @returns Array of absolute paths to image files
|
||||
*/
|
||||
function findImagesRecursively(dir: string): string[] {
|
||||
const imageExtensions = ['.png', '.jpg', '.jpeg', '.webp'];
|
||||
const imageExtensions = ['.png', '.jpg', '.jpeg', '.webp', '.mp4', '.avi', '.mov', '.mkv', '.wmv', '.m4v', '.flv'];
|
||||
let results: string[] = [];
|
||||
|
||||
const items = fs.readdirSync(dir);
|
||||
|
||||
Reference in New Issue
Block a user