Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on Mar 8, 2023. It is now read-only.
/unoconv-apiPublic archive

run unoconv as a webservice

License

NotificationsYou must be signed in to change notification settings

HeavyHorst/unoconv-api

Repository files navigation

unoconv-api is a simple http service that will call the unoconv executable, that in turn will call into the libreoffice api to convert documents.

For more info on unoconv and all possible conversions see theunoconv website.

Note: unoconv-api will serialize calls to the unoconv executable, since it doesn't support concurency.

Usage

Post the file you want to convert to the server and get the converted file in return.

The API for the webservice is /unoconv/{format-to-convert-to} so a docx to pdf conversion would be:

$ curl --form file=@myfile.docx http://127.0.0.1:3000/unoconv/pdf> myfile.pdf

There's a simple healthcheck api oncurl http://127.0.0.1:3000/unoconv/health that tries to convert some plain text to pdf,and returns "200 -OK" on success.

To compile just rungo build, the project usesgo 1.11 modules,so it'll download dependencies automatically.

systemd services

Two services, one for unoconv (the libreoffice listener), and the other for unoconv-api.Both are running with the same user, but also DynamicUser=true, so no need to create the useron the system. They share a runtime directory (/run/unoconv) for temporary files.

The services are bound together (BindsTo=), so if one is restarted the other will be too.unoconv-api implements a systemd watchdog too, that will test that conversions are possible.

# unoconv-api.service[Unit]Description=unoconv-api listenerBindsTo=unoconv.serviceAfter=unoconv.service[Service]Type=notifyDynamicUser=yesWatchdogSec=60User=unoconvGroup=unoconvRuntimeDirectory=unoconvRuntimeDirectoryPreserve=yesEnvironment=TMPDIR=/run/unoconvEnvironment=LISTEN_ADDR=127.0.0.1:3000ExecStart=/usr/local/bin/unoconv-apiSyslogIdentifier=unoconv-apiRestart=always[Install]WantedBy=multi-user.target
# unoconv.service[Unit]Description=unoconv libreoffice listener[Service]Type=simpleDynamicUser=yesUser=unoconvGroup=unoconvRuntimeDirectory=unoconvRuntimeDirectoryPreserve=yesStateDirectory=unoconvEnvironment=HOME=/var/lib/private/unoconv/ExecStart=/usr/bin/unoconv --listener --server=127.0.0.1 --port=2002SyslogIdentifier=unoconvRestart=always[Install]WantedBy=multi-user.target

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp