【发布时间】:2020-02-03 11:39:49
【问题描述】:
使用atlassian-python-api 1.15.1 模块和python 3.6 如何下载附加到 Confluence 页面的文件?
API 文档的page actions 部分提到了一个API get_attachments_from_content,通过它我可以成功获取所有页面附件的列表及其元数据。这个问题的末尾有一个例子,我可以通过打印results 键中的一项来获得什么。
我已经尝试过使用wget 模块下载附件:
fname = wget.download(base_server_name + attachment['_links']['download'])
但是,下载的文件不是页面上的文件,而是我有一个大的 HTML 文件,看起来像一个轻量级的登录页面。另外,我不确定在这里使用 wget 是否相关,我更喜欢使用 atlassian python API 本身的解决方案,因为它自己管理身份验证。
“结果”键:
{'id': '56427526', 'type': 'attachment', 'status': 'current', 'title': 'main.c', 'metadata': {'mediaType': 'application/八位字节流','标签':{'results':[],'start':0,'limit':200,'size':0,'_links':{'self':'https://foo.bar.com/confluence/rest/api/content/56427526/label'} }, '_expandable': {'currentuser': '', 'properties': '', 'frontend': '', 'editorHtml': ''}}, 'extensions': {'mediaType': 'application/octet -stream', 'fileSize': 363, 'comment': ''}, '_links': {'webui': '/pages/viewpage.action?pageId=14648850&preview=%2F14648850%2F56427526%2Fmain.c', '下载': '/download/attachments/14648850/main.c?version=1&modificationDate=1580726185883&api=v2', 'self': 'https://foo.bar.com/confluence/rest/api/content/56427526'}, '_expandable': {'container': '/rest/api/ content/14648850', '操作': '', 'children': '/rest/api/content/56427526/child', 'restrictions': '/rest/api/content/56427526/restriction/byOperation', 'history ':'/rest/api/content/56427526/history','祖先':'','body':'','版本':'','后代':'/rest/api/content/56427526/后代', '空格': '/res t/api/space/~Tim'}}
【问题讨论】:
标签: python confluence confluence-rest-api atlassian-python-api