sharing: text/plain provides now also Fields in output, doc update

This commit is contained in:
Peter Bieringer
2026-03-06 05:55:58 +01:00
parent 46780a48b0
commit 6a53b409d7
3 changed files with 56 additions and 35 deletions

View File

@@ -1091,6 +1091,8 @@ class BaseSharing:
writer = DictWriter(csv, fieldnames=DB_FIELDS_V1, delimiter=';')
if output_format == "csv":
writer.writeheader()
elif output_format == "txt":
writer.writeheader()
for entry in answer['Content']:
# TODO: Argument 1 to "writerow" of "DictWriter" has incompatible type "str"; expected "Mapping[str, Any]" [arg-type]
writer.writerow(entry) # type: ignore[arg-type]
@@ -1100,7 +1102,10 @@ class BaseSharing:
index = 0
for line in csv.getvalue().splitlines():
# create a shell array with content lines
answer_array.append('Content[' + str(index) + ']="' + line.replace('"', '\\"') + '"')
if index == 0:
answer_array.append('Fields="' + line + '"')
else:
answer_array.append('Content[' + str(index - 1) + ']="' + line.replace('"', '\\"') + '"')
index += 1
headers = {
"Content-Type": "text/csv"

View File

@@ -362,9 +362,21 @@ class TestSharingApiSanity(BaseTest):
logging.info("\n*** list/all (form->csv)")
form_array = []
_, headers, answer = self._sharing_api_form("all", "list", check=200, login="owner:ownerpw", form_array=form_array, accept="text/csv")
assert "Status=" not in answer
assert "Line=" not in answer
assert "ShareType" in answer
assert "token" in answer
assert "map" in answer
logging.info("\n*** list/all (form->text)")
form_array = []
_, headers, answer = self._sharing_api_form("all", "list", check=200, login="owner:ownerpw", form_array=form_array)
assert "Status='success'" in answer
assert "Lines=2" in answer
assert "Fields=" in answer
assert "Content[0]=" in answer
assert "Content[1]=" in answer
logging.info("\n*** delete token -> 200")
form_array = ["PathOrToken=" + token]