add update attachment

This commit is contained in:
Sarah 2022-09-05 23:05:54 +01:00
parent 5d2e08eabc
commit 23726bb417
1 changed files with 17 additions and 0 deletions

View File

@ -62,6 +62,23 @@ def get_attachment(wiki_url, token_id, token_secret, attachment_id):
return attachment_data_decoded
def update_attachment(wiki_url, token_id, token_secret, attachment_id, file_name, file_data, page_id):
headers = {}
headers.update(get_auth_header(token_id, token_secret))
data = {}
# Workaround for updating files: https://github.com/BookStackApp/BookStack/issues/3666
data["_method"] = "PUT"
data["name"] = file_name
data["uploaded_to"] = page_id
files = {}
files["file"] = file_data
requests.post(wiki_url + "/api/attachments/{}".format(attachment_id), headers=headers, data=data, files=files)
def delete_attachment(wiki_url, token_id, token_secret, attachment_id):
headers = {}
headers.update(get_auth_header(token_id, token_secret))