fix(content): respect current folder when uploading files (#211)

Previously the dashboard upload always sent files to root (folder_id=NULL)
because the upload flow never read or forwarded the current folder context.
The agency upload already handled this correctly — this applies the same pattern.

Changes:
- api.js: uploadContent() accepts optional folderId, appends to FormData
- content-library.js: handleFiles() passes state.currentFolderId
- content.js: POST / reads folder_id from multipart body
This commit is contained in:
Fabian Mendoza 2026-07-23 11:24:57 -04:00 committed by GitHub
parent 79ab849641
commit 9e0048eec2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 4 additions and 3 deletions

View file

@ -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();

View file

@ -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');

View file

@ -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);