-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add support for binary resource download (fixes #2108)
- Loading branch information
Showing
7 changed files
with
194 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash -e | ||
|
||
# This script queries the server for a non-existent binary resource | ||
# and verifies that we get the 404 error message. | ||
|
||
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" | ||
. "$SCRIPT_DIR/util.sh" | ||
|
||
BASE="http://localhost:8080/fhir" | ||
|
||
RANDOM_ID="$(uuidgen | tr '[:upper:]' '[:lower:]')" | ||
|
||
# Attempt to retrieve the Binary resource by ID | ||
echo "Verifying that the Binary resource with ID '$RANDOM_ID' does not exist." | ||
|
||
# Perform a GET request to retrieve the Binary resource by ID | ||
STATUS_CODE=$(curl -s -H "Accept: application/pdf" -o /dev/null -w '%{response_code}' "$BASE/Binary/$RANDOM_ID") | ||
|
||
# Test that the response code is 404 (Not Found), indicating the resource doesn't exist | ||
test "GET response code for Binary resource" "$STATUS_CODE" "404" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash -e | ||
|
||
# This script creates a binary resource and verifies that its binary content | ||
# can be read. | ||
|
||
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" | ||
. "$SCRIPT_DIR/util.sh" | ||
|
||
BASE="http://localhost:8080/fhir" | ||
|
||
# 10 KiB of random data, base64 encoded | ||
DATA="$(openssl rand -base64 10240 | tr -d '\n')" | ||
|
||
binary() { | ||
cat <<END | ||
{ | ||
"resourceType": "Binary", | ||
"contentType": "application/pdf", | ||
"data": "$DATA" | ||
} | ||
END | ||
} | ||
|
||
# Create a Binary resource that contains that data, and get its ID | ||
ID=$(curl -s -H 'Content-Type: application/fhir+json' -d "$(binary)" "$BASE/Binary" | jq -r .id) | ||
|
||
echo "Created Binary resource that contains the Random Data, with ID: $ID" | ||
|
||
# Retrieve the Binary resource, and Base64 encode it so it can be safely handled by Bash | ||
BASE64_ENCODED_BINARY_RESOURCE=$(curl -s -H 'Accept: application/pdf' "$BASE/Binary/$ID" | base64 | tr -d '\n') | ||
|
||
echo "Binary data retrieved. Verifying content..." | ||
|
||
test "Base64 encoding of Resource data" "$DATA" "$BASE64_ENCODED_BINARY_RESOURCE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters