Hi. Can you show an example of a multipart file upload? I'm trying the following which fails:
const addUploadCapabilities = requestHandler => (type, resource, params) => {
if (type === 'CREATE' && resource === 'books') {
// console.log(params.data.files);
if(params.data.files){
const files = params.data.files.map(file => file.rawFile)
const coverFile = files.filter(file => file.type === 'image/png');
// console.log(coverFile);
const bookFile = files.filter(file => file.type === 'application/pdf');
// console.log(bookFile);
const formData = new FormData();
formData.append("pdf",bookFile);
formData.append('bigCover', coverFile);
// console.log(formData);
requestHandler(type, resource, {
formData
})
}
}
return requestHandler(type, resource, params);
};
export default addUploadCapabilities;
Hi, and thanks for your question. As explained in the admin-on-rest contributing guide, the right place to ask a "How To" question, get usage advice, or troubleshoot your own code, is StackOverFlow.
This makes your question easy to find by the core team, and the developer community. Unlike Github, StackOverFlow has great SEO, gamification, voting, and reputation. That's why we chose it, and decided to keep GitHub issues only for bugs and feature requests.
So I'm closing this issue, and inviting you to ask your question at:
http://stackoverflow.com/questions/tagged/admin-on-rest
And once you get a response, please continue to hang out on the admin-on-rest channel in StackOverflow. That way, you can help newcomers and share your expertise!