hapifhir / hapi-fhir-jpaserver-starter

Apache License 2.0
393 stars 1.05k forks source link

binary_storage_enabled doesn't work #179

Open patrick-werner opened 3 years ago

patrick-werner commented 3 years ago

When enabling: binary_storage_enabledand persisting binaries above the threshold i get the following results:

tadgh commented 3 years ago

Hey @patrick-werner , This is what i would expect to see here. To actually stream the binary data down to your machine, you would need to use the $binary-access-read operation. e.g. [base]/Binary/5152/$binary-access-read with the appropriate content type. Or am I missing some nuance?

patrick-werner commented 3 years ago

Hi @tadgh,

the FHIR Spec states: "When the read request has some other type in the Accept header, then the content should be returned with the content type stated in the resource in the Content-Type header. E.g. if the content type in the resource is "application/pdf", then the content should be returned as a PDF directly. The _summary parameter does not apply in this case." https://www.hl7.org/fhir/binary.html#rest

So when doing a READ with application/pdf in the accepted header, the FHIR Server should return the raw PDF directly. Hapi returns an empty return body if setting the accept header to the original mime/type of the resource.

tadgh commented 3 years ago

Ahh I was indeed missing the nuance. Thanks much Patrick, will look at getting this implemented, i think it is a missing feature in core hapi-fhir.

github-actions[bot] commented 6 months ago

This issue is stale because it has been open 730 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 6 months ago

This issue was closed because it has been stalled for 5 days with no activity.

patrick-werner commented 5 months ago

reopening as this is still not working im 7.2.0 fyi @tadgh

lvbartow commented 5 months ago

Hello, I came across this bug yesterday and I've been letting some hair on my desk as I can't get content-negotiation working. You would suggest it is a server issue ? As you, I can successfully upload a Binary containing a PDF but I am not able to download it, even with good Content-Type on resource and properly set Accept header; the JSON Binary's description is always given instead. If you have any tips to get round of the problem before it is fixed... Thanks

tadgh commented 5 months ago

Did you attempt the $binary-access-read operation as I outlined above? e.g.

GET /Binary/[id]/$binary-access-read?path=Binary.data

^-- the above will stream the binary data in the content-type that is defined in the binary

@patrick-werner Yeah this was totally forgotten about. My apologies. Is there any chance you could write up a failing unit test for HAPI-FHIR? It is much easier to get OSS requests done if we can start with a failing test. I would recommend a test in this class.

lvbartow commented 5 months ago

Yes, even with the operation I'm not able to make it work. I am using a Docker Compose deployment of HAPI 7.2.0 R4 server. Here are some Postman screenshots :

image

image

tadgh commented 5 months ago

I assume you are using the JPAServerStarter. Have you enabled the binary_storage_enabled property? The code requires it to load that ResourceProvider. See: https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/8ef50832d3459d4eb35ecb4f116c580475acb59d/src/main/java/ca/uhn/fhir/jpa/starter/common/StarterJpaConfig.java#L353-L353

lvbartow commented 4 months ago

Hi, sorry to bother you again. I finally made $binary-access-read operation working with my config, but; with a valid b64 string, when i try to access i get this error : HAPI-1336: Content in resource of type Binary at path Binary.data is not appropriate for binary storage: base64Binary I am sure my b64 encoded data is valid as i can perfectly decode it from my own code or other online tool If you have any idea... big thx