我有一个如下路由器:
Router.route("/public/dicom/:dataid/:filename", function () {
var filePath = this.params.dataid + "/" + this.params.filename;
var basePath = process.env.HOME;
var filename = basePath + "/public/dicom/" + filePath;
// var filename = path.normalize(path.join(basePath, "public/dicom/" + filePath));
//console.log("+==================", filename)
var res = this.response;
if (!fs.existsSync(filename) ||
!fs.statSync(filename).isFile()) {
//console.log("==========================ERROR")
res.writeHead(404, { 'Content-Type': 'text/html' });
res.end('404: no such asset: ' + this.params.filename);
return;
}
var data = fs.readFileSync(filename);
res.writeHead(200, { 'Content-Type': "application/octet-stream", "charset": "binary" });
res.write(data);
res.end();
}, { where: "server" });
只需阅读DICOM文件的内容并返回客户端即可。响应就像 response data
在客户端站点中,我想将响应数据用作arrayBuffer数据。 请帮帮我!
PS:当我尝试使用响应数据时,我收到了一些错误,例如Uncaught TypeError: Cannot read property 'byteLength' of null
var dataOfPapaya = new Uint8Array(response.content);
console.log('dataOfPapaya', dataOfPapaya.byteLength);
var params = [];
// Configuration
params['binaryImages'] = [dataOfPapaya];
params['kioskMode'] = true;
params['showControls'] = false;
params["showOrientation"] = true;
params["radiological"] = true;
papaya.Container.startPapaya();
papaya.Container.resetViewer(0, params);
我使用papayajs来查看DICOM文件:https://github.com/rii-mango/Papaya