diff --git a/Bookstack.py b/Bookstack.py index 91e7293..11ffee9 100644 --- a/Bookstack.py +++ b/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))