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

fix(xmlupload): support uppercase file extensions (DEV-3095) #678

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/dsp_tools/commands/xmlupload/resource_create_client.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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