Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions archivist/assetattachments.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ def _identity(self, identity: str, attachment_id: str) -> str:

identity looks like:

[https://app.datatrails.ai/archivist/public]assets/xxxxxxx
[https://app.datatrails.ai/archivist/v2/public]assets/xxxxxxx

OR

[https://app.datatrails.ai/archivist/public]assets/xxxxxxx/events/yyyyyy
[https://app.datatrails.ai/archivist/v2/public]assets/xxxxxxx/events/yyyyyy

where the public URL is prefixed with the schema.

Expand All @@ -89,8 +89,8 @@ def _identity(self, identity: str, attachment_id: str) -> str:
if self._public:
# the public URL for the asset or event has to be changed
url = urlparse(identity)
root = "/".join(url.path.split(SEP)[:2])
asset_id = "/".join(url.path.split(SEP)[2:])
root = SEP.join(url.path.split(SEP)[:2])
asset_id = SEP.join(url.path.split(SEP)[3:])
new_url = url._replace(
path=f"{root}/{ASSETATTACHMENTS_SUBPATH}/{ASSETATTACHMENTS_LABEL}/{asset_id}/{uuid}"
)
Expand Down
5 changes: 3 additions & 2 deletions unittests/testpublicassetattachments.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@
}
URL = "https://app.datatrails.ai"
ASSET_UUID = "b2678528-0136-4876-ad56-904e12c4b4c6"
ASSET_ID = f"{URL}/{ROOT}/public{ASSETS_LABEL}/{ASSET_UUID}"
ASSET_ID = f"{URL}/{ROOT}/v2/public{ASSETS_LABEL}/{ASSET_UUID}"
ATTACHMENT_UUID = "abcdef28-0136-4876-ad56-904e12c4b4c6"
ATTACHMENT_ID = f"{ATTACHMENTS_LABEL}/{ATTACHMENT_UUID}"
SUBPATH = (
f"{ASSETATTACHMENTS_SUBPATH}/{ASSETATTACHMENTS_LABEL}/"
f"public{ASSETS_LABEL}/{ASSET_UUID}/{ATTACHMENT_UUID}"
)
LOGGER.debug("Subpath %s", SUBPATH)

LOGGER.debug("Subpath %s/%s/%s", URL, ROOT, SUBPATH)
RESPONSE = {
**PROPS,
"identity": ATTACHMENT_ID,
Expand Down