- Upload a PDF (e.g. somedoc.pdf) as a Complex Data Obs (works great!)
- Call Get on that Obs using REST (works great!)
- Read the uri property, which basically points to the value sub property of the Obs, e.g. http://localhost/openmrs/ws/rest/v1/obs/0f8b8084-cfc7-46d9-bb24-ecb40ef28e15/value
- Put that url in an tag
- When the user clicks on the link, it download the file, but the file is named file_01.file It would be better if the file was named file_01.pdf or even better somedoc.pdf.
It looks weird when the file downloaded is called file_xx.file, and I would like to avoid that if possible. Any suggestions?
I’ve attached a copy of the Requests and Responses that I am making.requests_and_responses.txt (2.3 KB)
Are you in the realm of the Ref App distro?
If yes, could this module be of any use to you: Visit Documents UI (VDUI). It supports PDF files out of the box.
I know that I’m not answering your question though. The developers behind the REST API for complex obs (@raff, @gutkowski) will most certainly do so, … if there’s a way, out of the current REST implementation, to set the file name upon downloading.
(1) You obtain the blob via REST then (2) you generate an hyperlink to the blob.
This is an example of how it could be done in Angular 1.x:
var downloadLink = angular.element('<a></a>');
What you’re interested in is the setting of the
@mksd, Thanks so much! This worked like a charm. And thanks for the link to the Visits Documents UI…I had looked at that, but only needed a very small part of the functionalty, so I decided not to use it.
@jcelano, thanks for bringing this up on talk. It’s a bug in REST, which can be easily fixed. Created an issue at https://issues.openmrs.org/browse/RESTWS-639