{ "success": true, "data": { "currentPath": "", "folders": [ { "name": "vacation", "path": "vacation", "imageCount": 45, "subfolderCount": 3, "lastModified": "2023-07-20T15:30:00Z" }, { "name": "family-photos", "path": "family-photos", "imageCount": 128, "subfolderCount": 5, "lastModified": "2023-06-15T09:20:00Z" } ], "images": [ { "name": "welcome.jpg", "path": "welcome.jpg", "size": 2048576, "lastModified": "2023-05-01T12:00:00Z", "dimensions": { "width": 1920, "height": 1080 } } ], "totalFolders": 2, "totalImages": 1 } }
Get folder structure and contents
curl http://localhost:3000/api/folders
curl "http://localhost:3000/api/folders?path=vacation/2023"
{ "success": true, "data": { "currentPath": "vacation/2023", "parentPath": "vacation", "folders": [ { "name": "summer", "path": "vacation/2023/summer", "imageCount": 23, "subfolderCount": 0, "lastModified": "2023-07-15T14:20:00Z" }, { "name": "winter", "path": "vacation/2023/winter", "imageCount": 18, "subfolderCount": 0, "lastModified": "2023-02-28T10:45:00Z" } ], "images": [ { "name": "beach-sunset.jpg", "path": "vacation/2023/beach-sunset.jpg", "size": 3145728, "lastModified": "2023-07-10T18:30:00Z", "dimensions": { "width": 2560, "height": 1440 } } ], "totalFolders": 2, "totalImages": 1 } }
async function loadFolderContents(folderPath = '') { try { const url = folderPath ? `/api/folders?path=${encodeURIComponent(folderPath)}` : '/api/folders'; const response = await fetch(url); const data = await response.json(); if (data.success) { return { folders: data.data.folders, images: data.data.images, currentPath: data.data.currentPath, parentPath: data.data.parentPath }; } else { throw new Error(data.error); } } catch (error) { console.error('Failed to load folder:', error); throw error; } } // Build folder navigation function buildFolderTree() { loadFolderContents() .then(data => { data.folders.forEach(folder => { console.log(`${folder.name}: ${folder.imageCount} images`); }); }) .catch(error => { console.error('Navigation failed:', error); }); }