File Uploads Tracked Entity Attributes

Hey all,

DHIS information:

  • Version: 2.27
  • Build revision: e33b34d
  • Build date: 2018-04-17 06:50
    I have added a tracked entity attribute with a value type of FILE. Once I have uploaded the file to “/api/fileResources” I get back the usual response and grab the id of the newly created file and assign it to the tracked entity attribute and it saves correctly.

The issue I am struggling with is retrieving the file once it has been uploaded. If anyone could assist that would be great!

Hey there Ranvir!

Are you trying to retrieve the file from the API/directly from the backend? Or does the user log in, open the tracker and try downloading the file from within the tracker app?

Markus

P.S. we are moving these topics to the community.dhis2.org - a great tool for collaborating, discussing in threads and building a searchable knowledge base at the same time.

Hey Markus,

We’re building a custom application that uses the DHIS API’s. I can get the file information when I call******“/api/fileResources/{id}”.** How do I actually view the uploaded file though or download it? I want to basically have an a tag that links to the file in our application.

···

Regards,

Ranvir Maharaj
Senior Software Developer

Avocado Chocolate

Software that is good for you

t. +27 78 7150186

e. ranvir@avochoc.com

46 Louis Botha Crescent

Port Elizabeth

www.avochoc.com

Hi Ranvir, most files can be retrieved from 2.31 at /api/fileResources//data, except for files related to data values and attribute values. The reason is they require a different type of access check.

In your case you are working with Tracked Entity Attributes, so you can find your files at /trackedEntityInstances///image

···

Stian Sandvold
Software developer, DHIS2

University of Oslo

http://www.dhis2.org

Hi Ranvir, most files can be retrieved from 2.31 at /api/fileResources//data, except for files related to data values and attribute values. The reason is they require a different type of access check.

In your case you are working with Tracked Entity Attributes, so you can find your files at /trackedEntityInstances///image

Hey Markus,

We’re building a custom application that uses the DHIS API’s. I can get the file information when I call******“/api/fileResources/{id}”.** How do I actually view the uploaded file though or download it? I want to basically have an a tag that links to the file in our application.

Regards,

Ranvir Maharaj
Senior Software Developer

Avocado Chocolate

Software that is good for you

t. +27 78 7150186

e. ranvir@avochoc.com

46 Louis Botha Crescent

Port Elizabeth

www.avochoc.com

Hey there Ranvir!
Are you trying to retrieve the file from the API/directly from the backend? Or does the user log in, open the tracker and try downloading the file from within the tracker app?

Markus

P.S. we are moving these topics to the community.dhis2.org - a great tool for collaborating, discussing in threads and building a searchable knowledge base at the same time.

Hey all,

DHIS information:

  • Version: 2.27
  • Build revision: e33b34d
  • Build date: 2018-04-17 06:50
    I have added a tracked entity attribute with a value type of FILE. Once I have uploaded the file to “/api/fileResources” I get back the usual response and grab the id of the newly created file and assign it to the tracked entity attribute and it saves correctly.

The issue I am struggling with is retrieving the file once it has been uploaded. If anyone could assist that would be great!


Mailing list: https://launchpad.net/~dhis2-users
Post to : dhis2-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-users
More help : https://help.launchpad.net/ListHelp


Mailing list: https://launchpad.net/~dhis2-users

Post to : dhis2-users@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-users

More help : https://help.launchpad.net/ListHelp


Stian Sandvold
Software developer, DHIS2

University of Oslo

http://www.dhis2.org

···

Hi Stian,

I am using v2.27. The URL you provided for me does not work (/trackedEntityInstances///image). I get a 404.

When I query the file, it has been stored. Does it only support images?

Hi again,

It seems like parts of my message was removed, I will update the original post with the correct urls:

/api/fileResources/(fileResource id)/data

/api/trackedEntityInstances/(tei id)/(attribute id)/image

Hi @Stian @Markus

I know since 2018 passed many years, but the question of retrieving saved FILE_RESOURCE type data still there. Could you point the API point how I can retrieve saved file from TEA?
I have tried:
/api/trackedEntityInstances/(tei id)/(attribute id)/data
/api/trackedEntityInstances/(tei id)/(attribute id)/file
/api/fileResources/(fileResource id)/data

DHIS version 2.39-2.40
Thank you

Regards,
Ulanbek