Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

save image as binary resource #169

Merged
merged 2 commits into from
Mar 12, 2024
Merged

save image as binary resource #169

merged 2 commits into from
Mar 12, 2024

Conversation

Wambere
Copy link
Contributor

@Wambere Wambere commented Mar 8, 2024

IMPORTANT: Where possible all PRs must be linked to a Github issue

Fixes #160

Engineer Checklist

  • I have run ./gradlew spotlessApply to check my code follows the project's style guide
  • I have built and run the efsity jar to verify my change fixes the issue and/or does not break the application

# and saves it as a Binary resource. It returns the id of the Binary resource if
# successful and 0 if failed
def save_image(image_source_url):
headers = {"Authorization": "Bearer " + config.product_access_token}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The assumption here is that these images are coming from a different source that requires different authorization from the fhir server

"request": {
"method": "PUT",
"url": "Binary/" + resource_id,
"ifMatch": "1"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll make the version and id configurable her when we add the final piece of code that calls this function when adding products so that edits also work

importer/main.py Outdated
"resource": {
"resourceType": "Binary",
"id": resource_id,
"contentType": "image/png",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how we use this contentType here or how important it is... from the current examples available as a source, there is no way to deduce this information, so just have this png here as a placeholder for now

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should be able to look at the binary date to figure this out, here's first hit, https://stackoverflow.com/questions/43580/how-to-find-the-mime-type-of-a-file-in-python, worth looking a bit more to see if there's something better

@Wambere Wambere requested a review from pld March 8, 2024 15:19
importer/main.py Outdated
"resource": {
"resourceType": "Binary",
"id": resource_id,
"contentType": "image/png",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should be able to look at the binary date to figure this out, here's first hit, https://stackoverflow.com/questions/43580/how-to-find-the-mime-type-of-a-file-in-python, worth looking a bit more to see if there's something better

@Wambere Wambere force-pushed the 160-product-images branch from f568e35 to 68c4be0 Compare March 12, 2024 11:30
@Wambere Wambere enabled auto-merge (squash) March 12, 2024 15:18
@Wambere Wambere requested a review from pld March 12, 2024 15:18
@Wambere Wambere merged commit 3d44e11 into main Mar 12, 2024
4 checks passed
@Wambere Wambere deleted the 160-product-images branch March 12, 2024 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EUSM - Add support for importing product images
2 participants