feat(admin/media): folders in the media library

- admin-files: fetchFolders / createFolder / deleteFolder + FolderItem; fetchFiles
  takes a folderId filter
- admin files upload route forwards target_folder_id so uploads land in the open folder
- FileManager: breadcrumb navigation, folder cards (open / delete), "+ new folder",
  folder-scoped file listing + upload. Folders hidden while searching (search spans all)

Uses the file-svc folder API (GET/POST/DELETE /v1/folders, folder_id list filter)
that already existed but had no UI. "Pick from library" was already wired via
FilePicker in FileUploadField.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-06-05 12:34:56 +03:30
parent 1142c38c62
commit 2918b7acbf
3 changed files with 148 additions and 9 deletions
+5
View File
@@ -29,6 +29,10 @@ export async function POST(req: NextRequest) {
if (!(file instanceof File)) {
return NextResponse.json({ error: "No file provided" }, { status: 400 });
}
// Optional: drop the upload into a specific media-library folder.
const folderId = form?.get("folder_id");
const targetFolderId =
typeof folderId === "string" && folderId ? folderId : undefined;
const auth = { Authorization: `Bearer ${token}` };
@@ -41,6 +45,7 @@ export async function POST(req: NextRequest) {
filename: file.name,
mime_type: file.type || "application/octet-stream",
size_bytes: file.size,
target_folder_id: targetFolderId,
}),
});
const presign = await presignRes.json().catch(() => null);