Updates to handle video in a dataset on ui

This commit is contained in:
Jaret Burkett
2025-03-26 12:15:28 -06:00
parent 4595965e06
commit e4526ad4a4
13 changed files with 228 additions and 58 deletions

View File

@@ -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 });
}

View File

@@ -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);