Uploading multiple files

While the Virtualpaper web page only allows uploading single files at a time, it is possible to upload multiple files or directories using the Virtualpaper API directly.

Example script for uploading a directory of PDFs directly with Bash:

#!/bin/bash

# Virtualpaper instance url
host="http://localhost:8000"

# Personal access token
Token can be found on user preferences page or by using the browser developer tools:
token="<a long string - find the token with browser's developer tools -> local storage -> 'auth'>"

# An expression matching the files that are being uploaded.
# Example will upload every pdf file from archive-directory.


# pattern to find documents to upload
files=(pdfs/*.pdf)
total=${#files[@]}
echo "Found total of $total files"
counter=0
for file in "${files[@]}"
do
    echo ""
    (( counter++ ))
    echo $counter / $total - $file.
    curl -X POST -H "Authorization: Bearer $token" -F "$file"=@"$file" -F name="$file" $host/api/v1/documents
done