Member-only story
Download OnlyOffice files using Terminal
How to download OnlyOffice files with CURL or WGET on a headless machine.
Ever tried a download link from OnlyOffice, only to hit a snag when using CURL or WGET? Instead of the file you expected, all you got was a frustrating 404 page in HTML format.
Fear not! The solution isn’t about mimicking a browser in your terminal, or even x-forwarding one- all it takes is providing the right headers
Solution
The following [URL]
fields are comprised from your link, which should be in the format:
https://<only office domain>/Products/Files/HttpHandlers/filehandler.ashx?action=download&fileid=<fileid number>&doc=<alphanumeric string>
We can now substitute this into one of the commands below.
CURL
curl -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36" \
-O "[URL]"
Some additional commands are using -o
to set the output file name, and -C
to allow us to resume an interrupted download:
curl -C - -o filename.extension "http://example.com/file-to-download"
WGET
wget -c --user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64)…