Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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.
III .  Proposed Solution

The proposed solution will consist of adding a new Mongo SchemaMongoose Schema. The documentation of how to create a Schema can be found here. For now, we can call it Attachment. The reason for that is because of each of the file uploaded to the platform, we have to efficiently manage the data, eliminating junk data in the platform that is not referenced anywhere.

However there, there is another use case where the user enters an external URL. For the external URL, we don't need to create a database record for it. The easiest way to implement this would be checking for the input field in the form. In the implementation of the form, there is a text field for images and uploader. Check if the input field is not empty then set the object as a URL string if the data is coming from the uploader then create a new database record

Having an attachment object in place, we use Mongoosecrudify to create a restful API to manage attachment record. The relation of the attachment object with person record is many to one, ie: each person will have one or many attachments uploaded.

Attachment schema for Mongo DB:

FieldDescriptionReason
IDAuto generated by MongooseThis will be convenience for API user retrieve information about the attachment
File NameA string represents file name of the attachment file uploadedWhen a user uploads a file or multiple files, each of the files will have a name of it. This will be useful for the user to remember what file they have uploaded when the user uploads a file or multiple files, each of the file will have a name of it. This will be useful for the user to remember what file they have uploaded
Type Enumerated type with 2 possible value which are Image and docsFor 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:

Code Block
languagejs
{
	"ownerID": "54asdfdf",
	"date": "Use Date object"
}


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

...