diff --git a/frontend/js/api.js b/frontend/js/api.js index a8c4d93..0489e19 100644 --- a/frontend/js/api.js +++ b/frontend/js/api.js @@ -83,9 +83,10 @@ export const api = { body: JSON.stringify({ parent_id: parentId || null }) }), deleteFolder: (id) => request(`/folders/${id}`, { method: 'DELETE' }), - uploadContent: async (file, onProgress) => { + uploadContent: async (file, onProgress, folderId) => { const formData = new FormData(); formData.append('file', file); + if (folderId) formData.append('folder_id', folderId); return new Promise((resolve, reject) => { const xhr = new XMLHttpRequest(); diff --git a/frontend/js/views/content-library.js b/frontend/js/views/content-library.js index 6452484..104283a 100644 --- a/frontend/js/views/content-library.js +++ b/frontend/js/views/content-library.js @@ -231,7 +231,7 @@ async function handleFiles(files) { await api.uploadContent(file, (pct) => { progressFill.style.width = pct + '%'; progressText.textContent = t('content.upload_progress_named_pct', { name: file.name, pct }); - }); + }, state.currentFolderId); showToast(t('content.toast.uploaded_named', { name: file.name }), 'success'); } catch (err) { showToast(t('content.toast.upload_failed_named', { name: file.name, error: err.message }), 'error'); diff --git a/server/routes/content.js b/server/routes/content.js index 5676a41..2d37523 100644 --- a/server/routes/content.js +++ b/server/routes/content.js @@ -99,7 +99,7 @@ router.post('/', checkStorageLimit, upload.single('file'), async (req, res) => { if (!req.file) return res.status(400).json({ error: 'No file uploaded' }); // #73: shared ingest - identical processing + insert for dashboard and agency uploads. - const content = await ingestUploadedFile({ file: req.file, userId: req.user.id, workspaceId: req.workspaceId }); + const content = await ingestUploadedFile({ file: req.file, userId: req.user.id, workspaceId: req.workspaceId, folderId: req.body.folder_id || null }); res.status(201).json(content); } catch (err) { console.error('Upload error:', err);