How to use HttpDataSetReader to load local .vti files?

const reader = vtkHttpDataSetReader.newInstance({
    fetchGzip: true,
});

reader.setUrl('/3d/headsq.vti', { loadData: true,}).then(() => {
    console.log(reader.getOutputData())
});

This code will throw error:


but when i use https it doesn't give an error:
 const reader = vtkHttpDataSetReader.newInstance({
    fetchGzip: true,
 });

 reader.setUrl('https://kitware.github.io/vtk-js/data/volume/headsq.vti', { loadData: true }).then(() => { 
    console.log(reader.getOutputData())
 });

When I set the loadData as false, can load the file,but when i use getPointData().getScalars().getRange(),will throw a error Cannot read properties of null (reading 'getRange')

reader.setUrl('/3d/headsq.vti', { loadData: false }).then(() => {
   volumeData = reader.getOutputData()
});

// some code ....
const initialRange = volumeData.getPointData().getScalars().getRange();

I created a project with vite and vue3, and the files are placed in the public/3d/ directory
image

The headsq.vti file is what I downloaded from the vtk.js example,Local files and files on https are exactly the same。

What is the question?

Did you do the following in your code?
import 'vtk.js/Sources/IO/Core/DataAccessHelper/JSZipDataAccessHelper';

Also if you say “Don’t load the data”, it is expected that you do not have data…

yes, I have imported JSZipDataAccessHelper

My question is why the same file, when loaded locally, will report an error。

Are you sure you got the full directory? HttpDataSetReader load directories, not a single file.

yes, i am sure.
This is the file directory:
image

The file has loaded, but the data structure is different from loading from https.

This is loaded from local file directory:
An error will be reported when executing pako.inflate(new Uint8Array(array.buffer)

This is loaded from https:

What is the extension of that file in data (.gz)? You should check what you are getting, but I’m pretty sure, you are not getting the content of that file, hence the issue…

I used the npm “serve” package for the local test and set up the npm proxy separately.