diff options
| author | diogo464 <[email protected]> | 2025-08-12 16:32:00 +0100 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2025-08-12 16:32:00 +0100 |
| commit | fcd70649f43a72dbbcbc79e524fbe3fe20261021 (patch) | |
| tree | 9bfa929fa7b6f740d6c15a9da550849bcda27150 /frontend/components | |
| parent | 70738d871decbcdec4f5535a7b6f57de26de7d2a (diff) | |
Replace complex /api/fs with simple /api/upload endpoint
- Create new /api/upload endpoint for file uploads with path query parameter
- Simplify DriveDirectoryClient upload logic to use POST instead of PUT
- Remove complex path encoding and AUTH header handling from client
- Remove unused /api/fs endpoint entirely - no longer needed
- Maintain all existing upload functionality (file size limits, auth, etc.)
- Test uploads to root directory and subdirectories - both working perfectly
Benefits:
- Cleaner API surface with single-purpose endpoints
- Simpler client code with less complexity
- Better separation of concerns
- Maintained backward compatibility for user experience
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
Diffstat (limited to 'frontend/components')
| -rw-r--r-- | frontend/components/drive/DriveDirectoryClient.tsx | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/frontend/components/drive/DriveDirectoryClient.tsx b/frontend/components/drive/DriveDirectoryClient.tsx index 548773a..c3c23a7 100644 --- a/frontend/components/drive/DriveDirectoryClient.tsx +++ b/frontend/components/drive/DriveDirectoryClient.tsx | |||
| @@ -182,16 +182,9 @@ export function DriveDirectoryClient({ path, files, breadcrumbs }: DriveDirector | |||
| 182 | const formData = new FormData() | 182 | const formData = new FormData() |
| 183 | formData.append('file', file) | 183 | formData.append('file', file) |
| 184 | 184 | ||
| 185 | // Construct the upload path (current path + filename) | 185 | // Use the new simple upload endpoint with path as query parameter |
| 186 | const uploadPath = path === '/' ? file.name : `${path.slice(1)}/${file.name}` | 186 | const response = await fetch(`/api/upload?path=${encodeURIComponent(path)}`, { |
| 187 | // Encode each path segment for the URL - Next.js will decode it back for the API | 187 | method: 'POST', |
| 188 | const encodedPath = uploadPath.split('/').map(encodeURIComponent).join('/') | ||
| 189 | |||
| 190 | const response = await fetch(`/api/fs/${encodedPath}`, { | ||
| 191 | method: 'PUT', | ||
| 192 | headers: { | ||
| 193 | 'AUTH': '1' // Development auth header | ||
| 194 | }, | ||
| 195 | body: formData | 188 | body: formData |
| 196 | }) | 189 | }) |
| 197 | 190 | ||
