This project will produce an executable "BookStackConsole" binary that takes a path to any local file and attempt to upload it to a BookStack page as an attachment using the API using a multipart/form-data request.
This is very simplistic and has been written with very little c#/.net knowledge, it is only mean to serve as a working example.
You will need .NET installed (Tested on .NET 5.0 on Fedora 35 Linux).
First, download all the files in the same directory as this readme to a folder on your system and run the below from within that directory.
# Setup
# ALTERNATIVELY: Open the program.cs file and add to the empty strings in the variables near the top.
export BS_URL=https://bookstack.example.com # Set to be your BookStack base URL
export BS_TOKEN_ID=abc123 # Set to be your API token_id
export BS_TOKEN_SECRET=123abc # Set to be your API token_secret
# Build with dotnet
dotnet build
# Running the script
./BookStackConsole/bin/Debug/net5.0/BookStackConsole <page_id> <file_path>
<page_id>
- The ID of the page you want to upload the attachment to.<file_path>
- File you want to upload as an attachment.
# Upload the 'cat-image-collection.zip' file as an attachment to page of ID 205
./BookStackConsole/bin/Debug/net5.0/BookStackConsole 205 ./cat-image-collection.zip