Skip to content

Commit

Permalink
fix(xmlupload): support uppercase file extensions (DEV-3095) (#678)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nora-Olivia-Ammann committed Dec 11, 2023
1 parent ad0c37c commit 24cb320
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/dsp_tools/commands/xmlupload/resource_create_client.py
Expand Up @@ -142,7 +142,7 @@ def _make_value(self, value: XMLValue, value_type: str) -> dict[str, Any]:
def _make_bitstream_file_value(bitstream_info: BitstreamInfo) -> dict[str, Any]:
local_file = Path(bitstream_info.local_file)
file_ending = local_file.suffix[1:]
match file_ending:
match file_ending.lower():
case "zip" | "tar" | "gz" | "z" | "tgz" | "gzip" | "7z":
prop = "knora-api:hasArchiveFileValue"
value_type = "ArchiveFileValue"
Expand Down
45 changes: 38 additions & 7 deletions testdata/xml-data/test-data-systematic.xml
Expand Up @@ -30,6 +30,24 @@
<allow group="ProjectAdmin">CR</allow>
</permissions>


<resource label="TestthingWithArk1"
restype=":TestThing2"
id="test_thing_with_ark_1"
ark="ark:/72163/4123-43ec6evb134-a.2022828">
<text-prop name=":hasSimpleText"><text encoding="utf8">Hello</text></text-prop>
</resource>

<resource label="Imagething-uppercase-extension"
restype=":ImageThing"
id="image_thing_8"
permissions="res-default">
<bitstream>testdata/bitstreams/test with uppercase extension.JPG</bitstream>
<text-prop name=":hasSimpleText">
<text permissions="prop-default" encoding="utf8">This is a Imagething, with an uppercase extension</text>
</text-prop>
</resource>

<resource label="TestthingOhnePermissions"
restype=":TestThing2"
id="test_thing_0"
Expand Down Expand Up @@ -320,6 +338,26 @@
</text-prop>
</resource>

<resource label="Imagething-multiple-dots"
restype=":ImageThing"
id="image_thing_6"
permissions="res-default">
<bitstream>testdata/bitstreams/test.with.multiple.dots.png</bitstream>
<text-prop name=":hasSimpleText">
<text permissions="prop-default" encoding="utf8">This is a Imagething, the name has multiple dots</text>
</text-prop>
</resource>

<resource label="Imagething-white-space"
restype=":ImageThing"
id="image_thing_7"
permissions="res-default">
<bitstream>testdata/bitstreams/test with whitespaces.png</bitstream>
<text-prop name=":hasSimpleText">
<text permissions="prop-default" encoding="utf8">This is a Imagething, the name has whitespaces</text>
</text-prop>
</resource>

<region label="Polygon in image"
id="region_1"
permissions="res-restricted"
Expand Down Expand Up @@ -805,13 +843,6 @@
</text-prop>
</resource>

<resource label="TestthingWithArk1"
restype=":TestThing2"
id="test_thing_with_ark_1"
ark="ark:/72163/4123-43ec6evb134-a.2022828">
<text-prop name=":hasSimpleText"><text encoding="utf8">Hello</text></text-prop>
</resource>

<resource label="TestthingWithArk2"
restype=":TestThing2"
id="test_thing_with_ark_2"
Expand Down

0 comments on commit 24cb320

Please sign in to comment.