New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating New Generic File Upload Controller #424
Creating New Generic File Upload Controller #424
Conversation
@Aman-Gupta-404 any update , please commit your progress , and make pr as draft |
Hi @salahlalami, I have created the files and the middleware for uploading the files. When I am testing the API using postman, I am getting a production issue, not sure why it is happening. Can use your help there. Updates that are done
Please do let me know if there are any issues or anything that I can update, I will do that |
middlewares/uploadMiddleware.js
Outdated
if (req.upload) { | ||
// fetching the file extention of the uploaded file | ||
let fileExtension = file.originalname.split('.')[1]; | ||
let _fileName = `${req.upload._id}.${fileExtension}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filename = orginalFileName+'-'+uniqueFileID+.${fileExtension}`;
orginalFileName = orginalFileName -> to lower case -> then use "npmjs.com/package/transliteration " to convert english-char
uniqueFileID = unique ID of 5 chars including [a-z,0-9]
models/erpModels/Upload.js
Outdated
type: String, | ||
}, | ||
removed: { | ||
type: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type boolean
default false
@Aman-Gupta-404 please review requested change , |
Hi @salahlalami, I have reviewed and made the changes to according to your request Apart from the changes, a few things I would like to mention.
Do let me know if there are any issues with this code, can work on it |
routes/erpRoutes/erpApi.js
Outdated
@@ -213,8 +213,8 @@ router.route('/offer/summary').get(catchErrors(offerController.summary)); | |||
// //____________________________________________ API for Upload controller _________________ | |||
|
|||
router.route('/public/upload/:model/:fieldId').post( | |||
createPublicUpload, | |||
uploadMiddleware.single('upload'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- could you add option to add multiply files
- Add option to add allowed file , ex only image
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @salahlalami, so regarding this
Can you tell me how do I make the option accessible from the backend, like should the options come from request params or from request body?
Secondly, can you tell me if a user is uploading 5 files (one file is of type image, and others of type PDF), and the user has passed the option to accept/allow only image type files, will the server reject all the other types of files and not upload it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Aman-Gupta-404
1- option is pre-defin config accessible only from the backend , default is single , typeFile is image by deafult, user can't decide . this is generic upload , we will use in different route
2- same this is should have some default , and other is option config is accessible only from the backend , user can't change it
there is no request params or from request body
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, i'll start working on it
Hi @salahlalami
Do check it, and let me know if there are any issues |
Thank you @Aman-Gupta-404 , could you record video to see how it work |
Hey @salahlalami, I have resolved the conflicts and tested the code, it works fine after reverting the changes I have also recorded the video to show how it works: See the video by clicking here do let me know if there are any other issues |
Thank you @Aman-Gupta-404 , we will merge it soon |
…r-controller Creating New Generic File Upload Controller
Working on the feature to upload files (issue #412 )