fix: align FilePond upload with the Node.js API and proxy gallery previews
Use the filepond-image field, parse the API envelope, and load private files through the authenticated content endpoint so uploads persist and images display.
This commit is contained in:
@@ -29,6 +29,19 @@ axiosInstance.interceptors.request.use(
|
||||
config.params.lang = lang;
|
||||
}
|
||||
|
||||
const isFormData = typeof FormData !== 'undefined' && config.data instanceof FormData;
|
||||
if (isFormData) {
|
||||
// Let the browser set multipart boundary — a bare multipart/form-data header breaks Multer
|
||||
if (typeof config.headers?.delete === 'function') {
|
||||
config.headers.delete('Content-Type');
|
||||
config.headers.delete('content-type');
|
||||
} else {
|
||||
delete config.headers['Content-Type'];
|
||||
delete config.headers['content-type'];
|
||||
}
|
||||
config.timeout = Math.max(config.timeout || 0, 120000);
|
||||
}
|
||||
|
||||
return config;
|
||||
},
|
||||
(error) => Promise.reject(error)
|
||||
|
||||
@@ -6,11 +6,11 @@ export const certificateApi = {
|
||||
search: (params) => axiosInstance.get('/certificates/admin/search', { params }),
|
||||
getOne: (id) => axiosInstance.get(`/certificates/admin/get-one/${id}`),
|
||||
getByUser: (userId) => axiosInstance.get(`/certificates/admin/by-user/${userId}`),
|
||||
create: (data) => axiosInstance.post('/certificates/admin/create', data),
|
||||
create: (data) => axiosInstance.post('/certificates/admin/create', data, { timeout: 120000 }),
|
||||
update: (id, data) => axiosInstance.put(`/certificates/admin/update/${id}`, data),
|
||||
delete: (id) => axiosInstance.delete(`/certificates/admin/delete/${id}`),
|
||||
uploadTemp: (formData) => axiosInstance.post('/files/admin/upload-temp', formData, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
timeout: 120000
|
||||
}),
|
||||
getSignedUrl: (filename, bucket = 'temp') =>
|
||||
axiosInstance.get(`/files/admin/signed-url/${encodeURIComponent(filename)}`, { params: { bucket } }),
|
||||
|
||||
@@ -5,7 +5,7 @@ export const documentApi = {
|
||||
getAll: (params) => axiosInstance.get('/documents/admin/get-all', { params }),
|
||||
getByUser: (userId) => axiosInstance.get(`/documents/admin/by-user/${userId}`),
|
||||
getOne: (id) => axiosInstance.get(`/documents/admin/get-one/${id}`),
|
||||
create: (data) => axiosInstance.post('/documents/admin/create', data),
|
||||
create: (data) => axiosInstance.post('/documents/admin/create', data, { timeout: 120000 }),
|
||||
update: (id, data) => axiosInstance.put(`/documents/admin/update/${id}`, data),
|
||||
delete: (id) => axiosInstance.delete(`/documents/admin/delete/${id}`),
|
||||
getMyDocuments: () => axiosInstance.get('/documents/user/my-documents')
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// /src/api/filesApi.js
|
||||
import axiosInstance from './axiosInstance';
|
||||
|
||||
export const filesApi = {
|
||||
uploadTemp: (formData) => axiosInstance.post('/files/admin/upload-temp', formData, {
|
||||
timeout: 120000
|
||||
}),
|
||||
getSignedUrl: (filename, bucket = 'temp') =>
|
||||
axiosInstance.get(`/files/admin/signed-url/${encodeURIComponent(filename)}`, { params: { bucket } }),
|
||||
getContent: (key, bucket) => axiosInstance.get('/files/admin/content', {
|
||||
params: { key, bucket },
|
||||
responseType: 'blob',
|
||||
timeout: 120000
|
||||
})
|
||||
};
|
||||
Reference in New Issue
Block a user