add get_attachment_contents
This commit is contained in:
parent
a23d9e6d2e
commit
b9e2b5bad9
12
WikiUtils.py
12
WikiUtils.py
|
@ -1,3 +1,4 @@
|
|||
import base64
|
||||
import json
|
||||
import requests
|
||||
|
||||
|
@ -34,3 +35,14 @@ def get_attachment_id(attachment_name, page_id, wiki_url, token_id, token_secret
|
|||
return attachment['id']
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def get_attachment_contents(attachment_id, wiki_url, token_id, token_secret):
|
||||
headers = {}
|
||||
headers.update(get_auth_header(token_id, token_secret))
|
||||
|
||||
r = requests.get(wiki_url + "/api/attachments/{}".format(attachment_id), headers=headers)
|
||||
attachment_data_encoded = json.loads(r.text)['content']
|
||||
attachment_data_decoded = base64.b64decode(attachment_data_encoded)
|
||||
|
||||
return attachment_data_decoded
|
||||
|
|
Loading…
Reference in New Issue