# Static file in web app

**URL:** <https://community.dhis2.org/t/static-file-in-web-app/42470>\
**Category:** App Development\
**Created:** [12 April 2021 14:07 UTC](https://community.dhis2.org/t/static-file-in-web-app/42470 "2021-04-12T14:07:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mahmud](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/mahmud/32/30730_2.png) [@Mahmud](https://community.dhis2.org/u/Mahmud)\
**Post date:** [12 April 2021 14:07 UTC](https://community.dhis2.org/t/static-file-in-web-app/42470/1 "2021-04-12T14:07:08Z")

</div>

We are working on a DHIS2 web app which has an Excel template file with certain metadata information. We allow uploading of Excel files filled with data - while uploading we use the template file for validating the uploaded file. Now, the template file is part of source code, means, it is part of the compiled app.

Is there any way so that we can have the Excel template out of the compiled app, so that if any update in the template file - we can just replace the file and the app continues working without compilation?

Does the dataStore allow Excel files instead of raw JSON?

---

<div class="post-metadata">

**Author:** ![austin](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/austin/32/41768_2.png) [@austin](https://community.dhis2.org/u/austin)\
**Post date:** [14 July 2021 11:03 UTC](https://community.dhis2.org/t/static-file-in-web-app/42470/2 "2021-07-14T11:03:37Z")

</div>

@Mahmud no, the dataStore only supports JSON types. You can use the fileResources API to upload a file into DHIS2 (see [the docs](https://docs.dhis2.org/en/develop/using-the-api/dhis-core-version-234/web-api.html#webapi_file_resources))

---

<div class="post-metadata">

**Author:** ![Mahmud](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/mahmud/32/30730_2.png) [@Mahmud](https://community.dhis2.org/u/Mahmud)\
**Post date:** [14 July 2021 11:42 UTC](https://community.dhis2.org/t/static-file-in-web-app/42470/3 "2021-07-14T11:42:57Z")

</div>

Thanks @austin we have already used the file resource.  
Although I am curious to know is there any limit on number of files that can be uploaded?  
Any DHIS2 settings that we may have to tweak if the number of files/size exceed?  
What is the folder where files are uploaded?

---

<div class="post-metadata">

**Author:** ![austin](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/austin/32/41768_2.png) [@austin](https://community.dhis2.org/u/austin)\
**Post date:** [14 July 2021 11:56 UTC](https://community.dhis2.org/t/static-file-in-web-app/42470/4 "2021-07-14T11:56:53Z")

</div>

[@dhis2-backend](https://community.dhis2.org/groups/dhis2-backend) should be able to answer that for you!

---

<div class="post-metadata">

**Author:** ![Stian](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/stian/32/136_2.png) [@Stian](https://community.dhis2.org/u/Stian)\
**Post date:** [15 July 2021 07:02 UTC](https://community.dhis2.org/t/static-file-in-web-app/42470/5 "2021-07-15T07:02:40Z")

</div>

Hi @Mahmud ,

There are no limits to number of files uploaded, for size, I think this might be restricted through your webserver like nginx, etc. But in DHIS2 we have no set limits at the moment.

Files are saved in your DHIS2\_HOME folder, unless your instance is configured to use a cloud provider. In the latter case, files are saved in the cloud as configured in dhis.conf.

A last note: Files can be uploaded to one of several “domains”. Each domain decide how the file is used. For example, files uploaded as a data or attribute value will only be accessible to some people. However, the domain called DOCUMENT are the one I would assume you want to look at. These are static files available to every logged in user, in theory.

---

<div class="post-metadata">

**Author:** ![Mahmud](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/mahmud/32/30730_2.png) [@Mahmud](https://community.dhis2.org/u/Mahmud)\
**Post date:** [8 August 2021 05:50 UTC](https://community.dhis2.org/t/static-file-in-web-app/42470/6 "2021-08-08T05:50:25Z")

</div>

Hi @Stian ,  
I see two APIs - api/fileResources & api/documents. Are they same? Somewhere I read that file resources uploaded must be ‘linked’ to any entity inside DHIS2 otherwise they may get deleted in 2 hours.

I am giving my scenario - an external application will upload some data as a ‘document’ (say CSV) via API. Later at some point (maybe 2-3 days later) a custom DHIS2 web app will look for this file and extract and import data into tracker.

So in my scenario when files are uploaded - we cannot link it with any resource immediately…any idea?

---

<div class="post-metadata">

**Author:** ![Stian](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/stian/32/136_2.png) [@Stian](https://community.dhis2.org/u/Stian)\
**Post date:** [7 September 2021 14:56 UTC](https://community.dhis2.org/t/static-file-in-web-app/42470/7 "2021-09-07T14:56:20Z")

</div>

Hi @Mahmud , sorry for the late reply.

Yes, any file you upload will need to be related to a resource inside dhis2. On the backend, document and fileResources are the same. A FileResource is a reference to a file, while DataValue, Document, etc are using that reference/fileResource to “have” a file.

If you upload something as a document, that is sufficient. We do have a cleanup job that would look for FileResources without any attachments, and remove them.
