# Load bundled .svg files (SOLVED)

**URL:** <https://forum.defold.com/t/load-bundled-svg-files-solved/41993>\
**Category:** Questions\
**Created:** [January 30, 2019, 10:30am UTC](https://forum.defold.com/t/load-bundled-svg-files-solved/41993 "2019-01-30T10:30:26Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [January 30, 2019, 10:30am UTC](https://forum.defold.com/t/load-bundled-svg-files-solved/41993/1 "2019-01-30T10:30:26Z")

</div>

I store .svg files in ` games/svg/`. They can’t be added to the actual collection, so I bundle them separately when building the project. I’ve added them to `bundle_resources/web/game/svg/` and they’re copied into this folder on export to HTML5.

 ![03](https://forum-defold.b-cdn.net/uploads/default/original/2X/0/0cb32a51066944dfd43124163bc395dbac847953.png)

Loading them doesn’t work, however, so the question is: How do I access the bundled files? I may be missing something basic here, so bear with me!

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [January 30, 2019, 10:55am UTC](https://forum.defold.com/t/load-bundled-svg-files-solved/41993/2 "2019-01-30T10:55:38Z")

</div>

> [@totebo](#):
>
> Loading them doesn’t work, however, so the question is: How do I access the bundled files?

How are you loading them?

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [January 30, 2019, 11:00am UTC](https://forum.defold.com/t/load-bundled-svg-files-solved/41993/3 "2019-01-30T11:00:36Z")

</div>

> [@britzl](#):
>
> How are you loading them?

I’m using `io.load`, and now that you said that, I should really be using `sys.load_resource`, should’t I? 🤔

Aside from that, is duplicating the files like I am the “right” way of doing it?

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [January 30, 2019, 11:22am UTC](https://forum.defold.com/t/load-bundled-svg-files-solved/41993/4 "2019-01-30T11:22:43Z")

</div>

Using sys.load\_resource I get an error: `/Users/niclasaberg/Bitbucket/Test/Defold/game/svg (Is a directory)`

With these settings:

 ![57](https://forum-defold.b-cdn.net/uploads/default/original/2X/6/6d64c1fd19cb5b6406116123be5c3b4c00101531.png)

 ![05](https://forum-defold.b-cdn.net/uploads/default/original/2X/7/7dcc265b6f33dcbaa552e78aff0d815150146920.png)

Directories should be fine, right?

> **[API reference (System)](https://defold.com/ref/sys/)**
>
> Defold is a free and open game engine used for development of console, desktop, mobile and web games.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [January 30, 2019, 11:30am UTC](https://forum.defold.com/t/load-bundled-svg-files-solved/41993/5 "2019-01-30T11:30:55Z")

</div>

> [@totebo](#):
>
> I’m using `io.load` , and now that you said that, I should really be using `sys.load_resource`

No, `sys.load_resources()` is for resources bundled using the `Custom Resources` field in `game.project`. Resources put in Custom Resources will be included in the game archive (ie not as individual files on disk), and you read them using `sys.load_resource()`.

`io.open()` and `io.read()` should be used when loading from filesystem. The root directory would be the location of the exe and you work from there. If you want files to be copied into your application bundle (ie inside the apk, ipa, app or the target folder when bundling for windows, linux and html5) you use Bundle Resources and the folder structure mentioned in the documentation.

Do note that the Bundle Resources will only be copied when you Bundle the application. When you do Project-\>Build the files will not be copied.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [January 30, 2019, 11:31am UTC](https://forum.defold.com/t/load-bundled-svg-files-solved/41993/6 "2019-01-30T11:31:23Z")

</div>

I’d probably use Custom Resources in your case actually.

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [January 30, 2019, 11:34am UTC](https://forum.defold.com/t/load-bundled-svg-files-solved/41993/7 "2019-01-30T11:34:23Z")

</div>

> [@britzl](#):
>
> I’d probably use Custom Resources in your case actually.

YES! It works. The final stumbling block was the formatting of the paths.

This doesn’t work:

 ![05](https://forum-defold.b-cdn.net/uploads/default/original/2X/7/7dcc265b6f33dcbaa552e78aff0d815150146920.png)

This works:

 ![53](https://forum-defold.b-cdn.net/uploads/default/original/2X/4/4d96e822b1a3ea01c8ea12930a7f6b6b802a32b6.png)

It looks like “Bundle Resources” and “Custom Resources” have to be formatted differently to work.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [January 30, 2019, 11:52am UTC](https://forum.defold.com/t/load-bundled-svg-files-solved/41993/8 "2019-01-30T11:52:02Z")

</div>

> [@totebo](#):
>
> It looks like “Bundle Resources” and “Custom Resources” have to be formatted differently to work.

Yes, this is a bit unfortunate to be honest… Created DEF-3748 to investigate why custom resources must not start with a forward slash.

---

<div class="post-metadata">

**Author:** ![Mattias\_Hedberg](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mattias_hedberg/32/433_2.png) [@Mattias\_Hedberg](https://forum.defold.com/u/Mattias_Hedberg)\
**Post date:** [January 31, 2019, 3:21pm UTC](https://forum.defold.com/t/load-bundled-svg-files-solved/41993/9 "2019-01-31T15:21:11Z")

</div>

It is also a bit annoying that in the game.project I specify `assets/definitions` as a custom resource but I need to load it like `sys.load_resource("/assets/definitions/file.json")`

In the project it shouldn’t start with a slash but when loading the file it have to.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [January 31, 2019, 7:13pm UTC](https://forum.defold.com/t/load-bundled-svg-files-solved/41993/10 "2019-01-31T19:13:51Z")

</div>

@Mattias_Hedberg please add this info to the ticket if you have the time!
