mirror of
https://github.com/screentinker/screentinker.git
synced 2026-08-16 07:13:12 -06:00
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:
parent
79ab849641
commit
9e0048eec2
|
|
@ -83,9 +83,10 @@ export const api = {
|
||||||
body: JSON.stringify({ parent_id: parentId || null })
|
body: JSON.stringify({ parent_id: parentId || null })
|
||||||
}),
|
}),
|
||||||
deleteFolder: (id) => request(`/folders/${id}`, { method: 'DELETE' }),
|
deleteFolder: (id) => request(`/folders/${id}`, { method: 'DELETE' }),
|
||||||
uploadContent: async (file, onProgress) => {
|
uploadContent: async (file, onProgress, folderId) => {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', file);
|
formData.append('file', file);
|
||||||
|
if (folderId) formData.append('folder_id', folderId);
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
|
|
|
||||||
|
|
@ -231,7 +231,7 @@ async function handleFiles(files) {
|
||||||
await api.uploadContent(file, (pct) => {
|
await api.uploadContent(file, (pct) => {
|
||||||
progressFill.style.width = pct + '%';
|
progressFill.style.width = pct + '%';
|
||||||
progressText.textContent = t('content.upload_progress_named_pct', { name: file.name, 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');
|
showToast(t('content.toast.uploaded_named', { name: file.name }), 'success');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
showToast(t('content.toast.upload_failed_named', { name: file.name, error: err.message }), 'error');
|
showToast(t('content.toast.upload_failed_named', { name: file.name, error: err.message }), 'error');
|
||||||
|
|
|
||||||
|
|
@ -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' });
|
if (!req.file) return res.status(400).json({ error: 'No file uploaded' });
|
||||||
|
|
||||||
// #73: shared ingest - identical processing + insert for dashboard and agency uploads.
|
// #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);
|
res.status(201).json(content);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Upload error:', err);
|
console.error('Upload error:', err);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue