Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility to load URL to zip file containing dcm files #434

Closed
martinpfannemueller opened this issue Dec 8, 2017 · 5 comments
Closed
Labels
question Further information is requested
Milestone

Comments

@martinpfannemueller
Copy link

martinpfannemueller commented Dec 8, 2017

Hi,

is it somehow possible to load a URL to a zip file with multiple dcm files directly? I found a ZipLoader in your code, however there is no example how to use it. If passing the URL is not possible, is it possible to load the zip file via the File Api? So downloading the zip file and creating the File variable to load this file then?

Thanks a lot!

EDIT:
I just tried it like this:

new JSZip.external.Promise(function (resolve, reject) {
            JSZipUtils.getBinaryContent(path, function(err, data) {
                if (err) {
                    reject(err);
                } else {
                    console.log(data);
                    var file = new File([data], "File.zip");
                    app.loadFiles([file]);
                    //resolve(data);
                }
            });
        })

However I only get this error in an alert box:

Error: Not a valid DICOM file (no magic DICM word found)

As I can unzip the file regularly with JSZip, I do not know, why this happens. Trying to unpack the zip file first looks like this:

new JSZip.external.Promise(function (resolve, reject) {
            JSZipUtils.getBinaryContent(path, function(err, data) {
                if (err) {
                    reject(err);
                } else {
                    resolve(data);
                }
            });
        }).then(function (data) {
            return JSZip.loadAsync(data);
        })
            .then(function success(zip) {
                var zipArray = [];
                Object.keys(zip.files).forEach(function(key) {
                    var file = zip.files[key];
                    zipArray.push(file);
                });
                app.loadFiles(zipArray);
            }, function failure(e) {
                console.error("failure", e);
            });

As dwv seems not to support the result of zip.files, as it is an object and not an array, I first put all objects into a new array. However this also does not work. I get this error:

TypeError: Failed to execute 'readAsArrayBuffer' on 'FileReader': parameter 1 is not of type 'Blob'.

Any ideas?

Best regards,
Martin

@arturojain
Copy link

#332

@ivmartel ivmartel added the question Further information is requested label Dec 11, 2017
@ivmartel ivmartel added this to the 0.23.0 milestone Dec 11, 2017
@ivmartel
Copy link
Owner

Hi Martin, loading zip files is supported via url or as a file. As an url, you just need to add the file path to an input as in: http://127.0.0.1:8080/viewers/mobile/index.html?input=/fileWithDicoms.zip

Check out the code of the zipLoader to see how it is done internally, especially the load method: https://github.com/ivmartel/dwv/blob/master/src/io/zipLoader.js#L86

@martinpfannemueller
Copy link
Author

Hi,

thanks a lot for the answers. I tried it the way you described it, however in Chrome the page simply crashes with the message, that there was an error showing this page. The reason I wanted to have one zip is to reduce the number of HTTP requests. As the zip files containing the dcm files are about 100 mb large, they probably are too large for JSZip you use internally. Unfortunately the console does not show any error. Additionally, the browser does not matter here.

@ivmartel
Copy link
Owner

This is more of a memory problem... 'theoretically' dwv can load zip files.

There are other issues open concerning memory management, for ex #342 and #397.

Can you close this issue?

@martinpfannemueller
Copy link
Author

Sure, thanks for clearing things up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants