# How to use HttpDataSetReader to load local .vti files？

**URL:** https://discourse.vtk.org/t/how-to-use-httpdatasetreader-to-load-local-vti-files/8266
**Category:** Web
**Created:** [April 11, 2022, 6:18am UTC](https://discourse.vtk.org/t/how-to-use-httpdatasetreader-to-load-local-vti-files/8266 "2022-04-11T06:18:09Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![zhangzhi93](https://discourse.vtk.org/user_avatar/discourse.vtk.org/zhangzhi93/32/4954_2.png) [@zhangzhi93](https://discourse.vtk.org/u/zhangzhi93)
#### Post date: [April 11, 2022, 6:18am UTC](https://discourse.vtk.org/t/how-to-use-httpdatasetreader-to-load-local-vti-files/8266/1 "2022-04-11T06:18:09Z")

</div>

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

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

```

This code will throw error:

 ![image](https://discourse.vtk.org/uploads/default/original/2X/0/0aa9a4f141b44120aa7c8a732fbb90d2452cfaeb.png)

* * *
but when i use https it doesn't give an error：

```auto
 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')`

```auto
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](https://discourse.vtk.org/uploads/default/original/2X/7/793da5bf88313eb8b91639469f2548db8103e6f7.png)

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

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [April 11, 2022, 2:47pm UTC](https://discourse.vtk.org/t/how-to-use-httpdatasetreader-to-load-local-vti-files/8266/2 "2022-04-11T14:47:19Z")

</div>

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…

---

<div class="post-metadata">

### Author: ![zhangzhi93](https://discourse.vtk.org/user_avatar/discourse.vtk.org/zhangzhi93/32/4954_2.png) [@zhangzhi93](https://discourse.vtk.org/u/zhangzhi93)
#### Post date: [April 12, 2022, 12:53am UTC](https://discourse.vtk.org/t/how-to-use-httpdatasetreader-to-load-local-vti-files/8266/3 "2022-04-12T00:53:38Z")

</div>

yes, I have imported JSZipDataAccessHelper

 ![image](https://discourse.vtk.org/uploads/default/original/2X/1/14612101431492462265e405fad0a8e867f6f211.png)

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

 ![image](https://discourse.vtk.org/uploads/default/original/2X/0/0aa9a4f141b44120aa7c8a732fbb90d2452cfaeb.png)

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [April 12, 2022, 2:37pm UTC](https://discourse.vtk.org/t/how-to-use-httpdatasetreader-to-load-local-vti-files/8266/4 "2022-04-12T14:37:08Z")

</div>

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

---

<div class="post-metadata">

### Author: ![zhangzhi93](https://discourse.vtk.org/user_avatar/discourse.vtk.org/zhangzhi93/32/4954_2.png) [@zhangzhi93](https://discourse.vtk.org/u/zhangzhi93)
#### Post date: [April 13, 2022, 1:33am UTC](https://discourse.vtk.org/t/how-to-use-httpdatasetreader-to-load-local-vti-files/8266/5 "2022-04-13T01:33:27Z")

</div>

yes, i am sure.  
This is the file directory:  
 ![image](https://discourse.vtk.org/uploads/default/original/2X/a/a0b15db3691ac304d075ca5d1271e9dc7f09c65f.png)

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)`

 ![image](https://discourse.vtk.org/uploads/default/original/2X/f/f5422fb84c13a9fd73e65af6d0a2b3f9dab8a84c.png)

This is loaded from https:

 ![image](https://discourse.vtk.org/uploads/default/original/2X/1/1e8128099187e50747fd27fb6f118c536dce04b4.png)

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [April 13, 2022, 2:38pm UTC](https://discourse.vtk.org/t/how-to-use-httpdatasetreader-to-load-local-vti-files/8266/6 "2022-04-13T14:38:44Z")

</div>

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…

---

<div class="post-metadata">

### Author: ![YHJ](https://discourse.vtk.org/user_avatar/discourse.vtk.org/yhj/32/6020_2.png) [@YHJ](https://discourse.vtk.org/u/YHJ)
#### Post date: [October 28, 2022, 4:11am UTC](https://discourse.vtk.org/t/how-to-use-httpdatasetreader-to-load-local-vti-files/8266/7 "2022-10-28T04:11:00Z")

</div>

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