add post/delete attachments methods
This commit is contained in:
parent
e7d3657c5d
commit
50617e94e8
21
Bookstack.py
21
Bookstack.py
|
@ -37,6 +37,20 @@ def get_attachment_id(wiki_url, token_id, token_secret, attachment_name, page_id
|
|||
return None
|
||||
|
||||
|
||||
def post_attachment(wiki_url, token_id, token_secret, filename, filedata, page_id):
|
||||
headers = {}
|
||||
headers.update(get_auth_header(token_id, token_secret))
|
||||
|
||||
data = {}
|
||||
data["name"] = filename
|
||||
data["uploaded_to"] = page_id
|
||||
|
||||
files = {}
|
||||
files["file"] = filedata
|
||||
|
||||
requests.post(wiki_url + "/api/attachments", data=data, files=files, headers=headers)
|
||||
|
||||
|
||||
def get_attachment(wiki_url, token_id, token_secret, attachment_id):
|
||||
headers = {}
|
||||
headers.update(get_auth_header(token_id, token_secret))
|
||||
|
@ -48,6 +62,13 @@ def get_attachment(wiki_url, token_id, token_secret, attachment_id):
|
|||
return attachment_data_decoded
|
||||
|
||||
|
||||
def delete_attachment(wiki_url, token_id, token_secret, attachment_id):
|
||||
headers = {}
|
||||
headers.update(get_auth_header(token_id, token_secret))
|
||||
|
||||
requests.delete(wiki_url + "/api/attachments/{}".format(attachment_id), headers=headers)
|
||||
|
||||
|
||||
def update_page(wiki_url, token_id, token_secret, page_id, markdown):
|
||||
headers = {}
|
||||
headers.update(get_auth_header(token_id, token_secret))
|
||||
|
|
Loading…
Reference in New Issue