I. Problem
The current system only supports file image upload. There are many issues will arise in the future with the current implementation. Because the image upload API can only handle Post request which makes it not restful API. The first sub-task is to make image upload API restful. Having image API to be restful increases consistency with other API endpoints. So as an API user, I can query for an image with an ID and it will return URL pointing to the location of that image. The functionality of the image API will stay the same, but it will be easier for admin to delete the image that is not being referenced anywhere in platform.
II. Idea
Shortly with the introduction of badges and documents upload, we will need an attachment system for the user to easily manage all their content uploaded. The design of the system will include another field in person schema which will be an array of attachments. So the user can reuse their uploaded assets for a new opportunity or a new activity.
A person record will contain a lot of attachments which could be CV file, avatar, banner profile image, etc. This could be easier for a user to have a page that they can manage things that they uploaded. The idea of an attachment management system comes from CMS where user can upload or remove attachment uploaded. However, the user can also use an external link which will cause some issue.
...
Attachment schema for Mongo DB:
Field | Description | Reason | |||||
---|---|---|---|---|---|---|---|
ID | Auto generated by Mongoose | This will be convenience for API user retrieve information about the attachment | |||||
File Name | When user upload a file or multiple files, each of the file will have a name of it. This will be useful for user to remember what file they have uploaded | ||||||
Type | For simplicity, we will only have 2 type which are documents and pictures. The field cloud be an enum type of those 2 | ||||||
MetaData | An example of how meta data object should contains:
| This meta data will contain information such as id of user who upload the image, the date and time of the file uploaded. Meta data will be helpful when user removed from the system. The system would just find all reference of the that user id and delete all database record about it |