Closed vjau closed 1 year ago
The code should work fine in node or browser. Try with one of the test datasets and if you still have issues post the full stack trace.
The dicom file used is the one provided in your examples/data
folder.
Stacktrace is here
/home/vincent/dev/temp/dcmjs-try/node_modules/dcmjs/build/dcmjs.js:829
this.view = new DataView(this.buffer);
^
TypeError: First argument to DataView constructor must be an ArrayBuffer
at new DataView (<anonymous>)
at new BufferStream (/home/vincent/dev/temp/dcmjs-try/node_modules/dcmjs/build/dcmjs.js:829:18)
at ReadBufferStream._createSuperInternal (/home/vincent/dev/temp/dcmjs-try/node_modules/dcmjs/build/dcmjs.js:632:25)
at new ReadBufferStream (/home/vincent/dev/temp/dcmjs-try/node_modules/dcmjs/build/dcmjs.js:1183:21)
at Function.readFile (/home/vincent/dev/temp/dcmjs-try/node_modules/dcmjs/build/dcmjs.js:3579:21)
at /home/vincent/dev/temp/dcmjs-try/main.js:4:43
at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:71:3)
I have made a repro here : https://github.com/vjau/dcmjs-try
Node v14.20.0 Ubuntu 20.04
Thanks for making the sample. Did you try changing this line to data.buffer
?
https://github.com/vjau/dcmjs-try/blob/1283caae8a16a37bfe5a4cc513297eaa0c3f7e33/main.js#L4
I tested with data.buffer
and it appears to work. Can you confirm. I did run into [this issue](https://github.com/dcmjs-org/dcmjs/issues/319}. If you are working on nodejs could you provide a PR to fix that?
It's indeed working replacing data
with data.buffer
I will look into your issue.
Hi, i'm trying this library for the first time and have trouble with basic operations, trying to run this in node.
With this code and provided test dicom
I get following error
I am not an expert in node binary handling, but i suppose a node
Buffer
should be accepted as anArrayBuffer
.Or is this project only for the browser ?
Thank you.