-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add `writeBulkData` method for bulk data at `multipartWriter` class. - Add bulk data object type definition - Use multipartWriter refactoring of original **single** bulkdata API - Add `bulkdata` API in `api/diocm-web` directory - Fix incorrect multipart structure. Remove `CRLF` in `writeContentLength` and move in `writeBufferData` to avoid the content-length is not last header. > The correct structure --++++CRLF Content-Type: media-type CRLF Content-Location: url CRLF (Content-Length: uint CRLF / Content-Encoding: encoding CRLF) [Content-Description: {description} CRLF] CRLF payload CRLF --++++CRLF Content-Type: media-type CRLF . . . payload CRLF --++++CRLF zh_TW: - 在 `multipartWriter` 新增 `writeBulkData` 功能以處理 bulkdata 的 multipart 資料 - 新增 bulk data 物件聲明 - 使用 multipartWriter 重構原本取得單個 bulkdata 的 API - `api/diocm-web` 新增 `bulkdata` 的 API - 修正錯誤的 multipart 結構。移除在`writeContentLength`內的一個 `CRLF`並搬移到`writeBufferData` 以防 content-length 不是最後一個 header。 > 正確的 multipart 結構 --++++CRLF Content-Type: media-type CRLF Content-Location: url CRLF (Content-Length: uint CRLF / Content-Encoding: encoding CRLF) [Content-Description: {description} CRLF] CRLF payload CRLF --++++CRLF Content-Type: media-type CRLF . . . payload CRLF --++++CRLF
- Loading branch information
1 parent
eec3d8a
commit e2d3d9a
Showing
6 changed files
with
157 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
const mongodb = require("../../../models/mongodb"); | ||
const _ = require('lodash'); | ||
const uuid = require('uuid'); | ||
const fs = require('fs'); | ||
const { | ||
MultipartWriter | ||
} = require('../../../utils/multipartWriter'); | ||
|
||
/** | ||
* | ||
* @param {import('express').Request} req | ||
* @param {import('express').Response} res | ||
* @returns | ||
*/ | ||
module.exports = async function (req, res) { | ||
let { | ||
studyID, | ||
seriesID, | ||
instanceID | ||
} = req.params; | ||
let bulkDataList = await mongodb["dicomBulkData"].find({ | ||
$and: [ | ||
{ | ||
$or : [ | ||
{ | ||
studyUID: studyID | ||
}, | ||
{ | ||
seriesUID: seriesID | ||
}, | ||
{ | ||
instanceUID: instanceID | ||
} | ||
] | ||
|
||
} | ||
] | ||
}) | ||
.exec(); | ||
|
||
let multipartWriter = new MultipartWriter([], res, req); | ||
multipartWriter.setHeaderMultipartRelatedContentType("application/octet-stream"); | ||
let isFirst = true; | ||
for (let bulkData of bulkDataList) { | ||
await multipartWriter.writeBulkData(bulkData, isFirst); | ||
isFirst = false; | ||
} | ||
await multipartWriter.writeFinalBoundary(); | ||
|
||
return res.end(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* @typedef {object} BulkData | ||
* @property {string} studyUID | ||
* @property {string} seriesUID | ||
* @property {string} instanceUID | ||
* @property {string} filename | ||
* @property {string} binaryValuePath The json path of the binary value | ||
* | ||
*/ | ||
|
||
const BulkData = true; | ||
|
||
export {BulkData}; |