The user can upload two different types of files. xml or csv. Both files contain the same types of content, but represented according to their respective format. The system allows the user to upload either of these two files. The system should process the two files and normalize them to json format. When normalizing, the user will inform if he wants to save the result locally or in a database in the cloud.
Read file, transform data and save to local or to mongo atlas
- Create an account on mongo atlas Link Here
- Set your credential on .env file
- Run the test
yarn test
- Run the project
yarn dev
destination: Local or Mongo
POST http://localhost:3000/upload
BODY form-data
the sample files you can find on
src/data
{
file: sample.csv
destination: Local
}
PAYLOAD
{
"success": true
}
the get route find documents on mongodb
GET http://localhost:3000/upload?limit=2
{
{
"docs": [
{
"_id": "624a0077642d164fd3dcda65",
"Transaction": "Invoice0000001",
"Amount": "1,000.00",
"CurrencyCode": "USD",
"TransactionDate": "20/02/2019 12:33:16",
"Status": "Approved"
},
{
"_id": "624a0077642d164fd3dcda66",
"Transaction": "Invoice0000002",
"Amount": "300.00",
"CurrencyCode": "USD",
"TransactionDate": "21/02/2019 02:04:59",
"Status": "Failed"
}
]
},
"count": 12
}
- Copy the files to your project
- Call the function
processFileService
- You can provide a file from uploaded
Any question feel free to message me Linkedin