# \[SOLVED\] File.size on the glB-file loading

**URL:** <https://forum.playcanvas.com/t/solved-file-size-on-the-glb-file-loading/13802>\
**Category:** Help & Support\
**Created:** [June 27, 2020, 10:31am UTC](https://forum.playcanvas.com/t/solved-file-size-on-the-glb-file-loading/13802 "2020-06-27T10:31:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thomas\_Due\_Nielsen](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/thomas_due_nielsen/32/5284_2.png) [@Thomas\_Due\_Nielsen](https://forum.playcanvas.com/u/Thomas_Due_Nielsen)\
**Post date:** [June 27, 2020, 10:31am UTC](https://forum.playcanvas.com/t/solved-file-size-on-the-glb-file-loading/13802/1 "2020-06-27T10:31:19Z")

</div>

I am in doubt if this is correct? (have already been looking at:

> **[Asset | PlayCanvas API Reference](https://api.playcanvas.com/classes/Engine.Asset.html)**
>
> Combined API reference manual for PlayCanvas

So trying:

```javascript
        app.assets.loadFromUrlAndFilename(self.url, null, "container", function (err, asset) {
        console.log("FileSize: "+ asset.file.size);
            // Add the loaded scene to the hierarchy
            self.entity.addComponent('model', {
                asset: asset.resource.model,  
                material: self.app.assets.get(30625063).resource
            });

```

- where the output is ‘FileSize: undefined’.

Going a bit further:

```javascript
        app.assets.loadFromUrlAndFilename(self.url, null, "container", function (err, asset) {
           // Add the loaded scene to the hierarchy
            self.entity.addComponent('model', {
                asset: asset.resource.model,  
                material: self.app.assets.get(30625063).resource,
                file: file.size
            }); 
            console.log("FileSize: "+ file.size);

```

- which fails (even before webupload :-/ )

---

<div class="post-metadata">

**Author:** ![yaustar](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/yaustar/32/2268_2.png) [@yaustar](https://forum.playcanvas.com/u/yaustar)\
**Post date:** [June 27, 2020, 11:12pm UTC](https://forum.playcanvas.com/t/solved-file-size-on-the-glb-file-loading/13802/2 "2020-06-27T23:12:56Z")

</div>

Looking at the engine code, the properties on the `file` object are not guaranteed. It’s extra meta data that needs to be explicitly set. My guess is that for Editor projects, this data is given but for files from loadFromUrlAndFilename, you can see from the engine code that it only contains the URL and filename: [https://github.com/playcanvas/engine/blob/master/src/asset/asset-registry.js#L480](https://github.com/playcanvas/engine/blob/master/src/asset/asset-registry.js#L480)

Added issue to updated documentation: [https://github.com/playcanvas/engine/issues/2214](https://github.com/playcanvas/engine/issues/2214)

As far as I know, there isn’t a way to get the file size of the asset that you have downloaded.

Your best bet is to get the size of file via XHR (e.g. [https://bitexperts.com/Question/Detail/3316/determine-file-size-in-javascript-without-downloading-a-file](https://bitexperts.com/Question/Detail/3316/determine-file-size-in-javascript-without-downloading-a-file))

The asset object is meant to hold the meta data about the resource type it represents so it only holds the data that the developer gives (the URL, filename, type etc) and then it loads the resource based on that data.

---

<div class="post-metadata">

**Author:** ![Thomas\_Due\_Nielsen](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/thomas_due_nielsen/32/5284_2.png) [@Thomas\_Due\_Nielsen](https://forum.playcanvas.com/u/Thomas_Due_Nielsen)\
**Post date:** [June 28, 2020, 12:47am UTC](https://forum.playcanvas.com/t/solved-file-size-on-the-glb-file-loading/13802/3 "2020-06-28T00:47:55Z")

</div>

Ok sounds like a thorough explanation … I have a backup plan but worth the try with this otherwise 1st priority
