Skip to content

Commit

Permalink
refactor: swap args(req, res) of MultipartWriter
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinlinlee committed Apr 1, 2023
1 parent 5677940 commit 667267b
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class RetrieveRenderedInstanceFramesController extends Controller {
}
throw new Error(`Can not process this image, instanceUID: ${instanceFramesObj.instanceUID}, frameNumber: ${this.request.frameNumber[0]}`);
} else {
let multipartWriter = new MultipartWriter([], this.response, this.request);
let multipartWriter = new MultipartWriter([], this.request, this.response);
await renderedService.writeSpecificFramesRenderedImages(this.request, frameNumber, instanceFramesObj, multipartWriter);
multipartWriter.writeFinalBoundary();

Expand Down
2 changes: 1 addition & 1 deletion api/dicom-web/controller/WADO-RS/rendered/instances.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class RetrieveRenderedInstancesController extends Controller {
let imagePathObj = await mongoose.model("dicom").getPathOfInstance(this.request.params);

if (imagePathObj) {
let multipartWriter = new MultipartWriter([], this.response, this.request);
let multipartWriter = new MultipartWriter([], this.request, this.response);
let instanceFramesObj = await renderedService.getInstanceFrameObj(imagePathObj);
let dicomNumberOfFrames = _.get(instanceFramesObj, "00280008.Value.0", 1);
dicomNumberOfFrames = parseInt(dicomNumberOfFrames);
Expand Down
2 changes: 1 addition & 1 deletion api/dicom-web/controller/WADO-RS/rendered/series.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class RetrieveRenderedSeriesController extends Controller {
let instancesInSeries = await mongoose.model("dicomSeries").getPathGroupOfInstances(this.request.params);

if (instancesInSeries.length > 0) {
let multipartWriter = new MultipartWriter([], this.response, this.request);
let multipartWriter = new MultipartWriter([], this.request, this.response);

for(let imagePathObj of instancesInSeries) {
let instanceFramesObj = await renderedService.getInstanceFrameObj(imagePathObj);
Expand Down
2 changes: 1 addition & 1 deletion api/dicom-web/controller/WADO-RS/rendered/study.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class RetrieveRenderedStudyController extends Controller {
let pathGroupOfInstancesInStudy = await mongoose.model("dicomStudy").getPathGroupOfInstances(this.request.params);

if (pathGroupOfInstancesInStudy.length > 0) {
let multipartWriter = new MultipartWriter([], this.response, this.request);
let multipartWriter = new MultipartWriter([], this.request, this.response);

for(let imagePathObj of pathGroupOfInstancesInStudy) {
let instanceFramesObj = await renderedService.getInstanceFrameObj(imagePathObj);
Expand Down
6 changes: 3 additions & 3 deletions api/dicom-web/controller/WADO-RS/service/WADO-RS.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const multipartFunc = {
code: 404,
message: `not found, Study UID: ${iParam.studyUID}`
};
let multipartWriter = new MultipartWriter(imagesPath, res, req);
let multipartWriter = new MultipartWriter(imagesPath, req, res);
return multipartWriter.writeDICOMFiles(type);
},
getSeriesDICOMFiles: async (iParam, req, res, type) => {
Expand All @@ -42,7 +42,7 @@ const multipartFunc = {
code: 404,
message: `not found, Series UID: ${iParam.seriesUID}, Study UID: ${iParam.studyUID}`
};
let multipartWriter = new MultipartWriter(imagesPath, res, req);
let multipartWriter = new MultipartWriter(imagesPath, req, res);
return multipartWriter.writeDICOMFiles(type);
},
getInstanceDICOMFile: async (iParam, req, res, type) => {
Expand All @@ -52,7 +52,7 @@ const multipartFunc = {
code: 404,
message: `not found, Instance UID: ${iParam.instanceUID}, Series UID: ${iParam.seriesUID}, Study UID: ${iParam.studyUID}`
};
let multipartWriter = new MultipartWriter([imagePath], res, req);
let multipartWriter = new MultipartWriter([imagePath], req, res);
return multipartWriter.writeDICOMFiles(type);
}
}
Expand Down
6 changes: 3 additions & 3 deletions utils/multipartWriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ class MultipartWriter {
/**
*
* @param {Array<ImagePathObj>} imagePathObjList The path list of the images
* @param {import('express').Response} res The express response
* @param {import('express').Request} req
* @param {import('express').Response} res The express response
*/
constructor(imagePathObjList, res, req = {}) {
constructor(imagePathObjList, req={}, res) {
this.BOUNDARY = `${uuid.v4()}-${uuid.v4()}-raccoon`;
this.imagePathObjList = imagePathObjList;
this.res = res;
this.req = req;
this.res = res;
}

/**
Expand Down

0 comments on commit 667267b

Please sign in to comment.