# Nuage module – Dashboard (Mes fichiers) This guide explains how to add a **Mes fichiers** (My files) section to your client dashboard so that logged-in users can browse, download, and upload files/folders that have been shared with them by an admin. ## Prerequisites - Auth and dashboard set up as in [Client dashboard and user features](../../features/auth/README-dashboard.md). - Nuage module enabled (`ZEN_MODULE_NUAGE=true`). - **User–share link**: In the admin Nuage explorer, an admin must have created a share targeting a specific user (by their email/account). The share is stored in `zen_nuage_shares` with `user_id` set to the user. ## API for "my shares" When a user is authenticated, you can load all active file/folder shares assigned to them with: | Endpoint | Method | Auth | Description | |----------|--------|------|-------------| | `/zen/api/nuage/me` | GET | Session (user) | Returns all active shares assigned to the current user. | | `/zen/api/nuage/shared` | GET | Session (user) | Returns the contents of a shared folder (subfolders + files). | | `/zen/api/nuage/download` | GET | Session (user) | Returns a signed download URL for a file inside a share. | | `/zen/api/nuage/upload` | POST | Session (user) | Uploads a file into a shared folder (collaborator permission only). | ### GET `/zen/api/nuage/me` **Example response (user has active shares):** ```json { "success": true, "shares": [ { "id": 1, "token": "abc123...", "target_type": "folder", "target_id": "42", "target_name": "Contrats 2025", "permission": "reader", "expires_at": null }, { "id": 2, "token": "def456...", "target_type": "file", "target_id": "17", "target_name": "Devis-2025-01.pdf", "permission": "collaborator", "expires_at": "2025-12-31T23:59:59.000Z" } ] } ``` **When the user has no active shares:** ```json { "success": true, "shares": [] } ``` ### GET `/zen/api/nuage/shared` **Query parameters:** - `shareId` *(required)* – The share `token` returned by `/nuage/me`. - `folder` *(optional)* – ID of a subfolder to navigate into. **Example response:** ```json { "success": true, "folders": [ { "id": "10", "name": "Sous-dossier", "created_at": "2025-03-01T10:00:00.000Z" } ], "files": [ { "id": "55", "display_name": "rapport.pdf", "mime_type": "application/pdf", "size": 204800 } ], "breadcrumb": [ { "id": "10", "name": "Sous-dossier" } ], "permission": "reader" } ``` ### GET `/zen/api/nuage/download` **Query parameters:** - `fileId` *(required)* – ID of the file to download. - `shareId` *(required)* – The share `token`. Returns a signed URL to download the file directly from storage. ### POST `/zen/api/nuage/upload` Only available for shares with `permission: "collaborator"` targeting a folder. **Form data fields:** - `file` *(required)* – The file to upload. - `shareId` *(required)* – The share `token`. - `folderId` *(optional)* – ID of a subfolder to upload into (must be within the share scope). All requests must send the session cookie (e.g. `fetch(..., { credentials: 'include' })`). ## Adding the Mes fichiers section to the dashboard ### 1. Protected page Create a dashboard page that requires login and renders the Nuage section: ```js // app/dashboard/fichiers/page.js (Server Component) import { protect } from '@hykocx/zen/auth'; import ClientNuageSection from '@hykocx/zen/nuage/dashboard'; export default async function DashboardFichiersPage() { await protect({ redirectTo: '/auth/login' }); return (