[x] Update the endpoint POST /files endpoint to start a background processing for generating thumbnails for a file of type image:
[x] Create a Bull queue fileQueue
[x] When a new image is stored (in local and in DB), add a job to this queue with the userId and fileId
[x] Create a file worker.js:
[x] By using the module Bull, create a queue fileQueue
[x] Process this queue:
[x] If fileId is not present in the job, raise an error Missing fileId
[x] If userId is not present in the job, raise an error Missing userId
[x] If no document is found in DB based on the fileId and userId, raise an error File not found
[x] By using the module image-thumbnail, generate 3 thumbnails with width = 500, 250 and 100 - store each result on the same location of the original file by appending _<width size>
[x] Update the endpoint GET /files/:id/data to accept a query parameter size:
[x] size can be 500, 250 or 100
[x] Based on size, return the correct local file
[x] If the local file doesn’t exist, return an error Not found with a status code 404
[x] Update the endpoint
POST /files
endpoint to start a background processing for generating thumbnails for a file of typeimage
:Bull
queuefileQueue
userId
andfileId
[x] Create a file worker.js:
Bull
, create a queuefileQueue
fileId
is not present in the job, raise an errorMissing fileId
userId
is not present in the job, raise an errorMissing userId
fileId
anduserId
, raise an errorFile not found
image-thumbnail
, generate 3 thumbnails withwidth
= 500, 250 and 100 - store each result on the same location of the original file by appending_<width size>
[x] Update the endpoint
GET /files/:id/data
to accept a query parameter size:size
can be500
,250
or100
size
, return the correct local fileNot found
with a status code404
Required Paths:
utils/
,controllers/FilesController.js
,worker.js
.