Description
Problem:
There is a need to create a new generic file uploadController.js file with a model. This controller should be located inside the middlewaresControllers directory.
Solution:
To address this problem, the following steps need to be taken:
Create a new model named Upload within the coreModels directory. This model will have the following fields:
modelName: The name of the model.
fieldId: The ID of the field.
enabled: A flag indicating whether the upload is enabled or not.
isPublic: A flag indicating whether isPublic or protected.
userID : userID who upload
isSecure : if true , only users who upload can see
removed: A flag indicating whether the upload has been removed or not.
path: The path to the uploaded file.
The File should upload to upload folder , inside modelName folder , the file should have a name of document id of (UploadCollection)
Add a new route to the coreRoutes file. This route should handle the URL pattern public/upload/:model/:fieldId.
Add a new route to the coreRoutes file. This route should handle the URL pattern private/upload/:model/:fieldId.
By following these steps, a new generic upload controller can be created with the necessary model and route structure.