Running BuildVu from cURL via an application server
1. For instructions on setting up BuildVu on an application server, take a look at our tutorials.
2. Once hosted, you can interact with BuildVu using cURL requests.
For example, if the application server endpoint is localhost:8080/microservice-example, the following cURL request will send a POST request to BuildVu and 'myfile.pdf' as the file to be converted.
curl -X POST -F "input=upload" -F "file=@myfile.pdf" http://localhost:8080/microservice-example/buildvu
Alternatively, the application server can download the file from a URL. To do this, change the POST request so that the input parameter is set to 'download' and use 'url' instead of 'file', providing a URL instead of a file path. For example:
curl -X POST -F "input=download" -F "url=www.example.com/myfile.pdf" http://localhost:8080/microservice-example/buildvu
The response will be in JSON format and will indicate where the converted output can be retrieved.
{"uuid" : "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"}
3. Using the provided UUID, you can send a cURL request to poll for the status of the conversion:
curl http://localhost:8080/microservice-example/buildvu?uuid=aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
The response will be in JSON format and provide details about the conversion:
{ "state" : "processed", "downloadUrl" : "output/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/myfile.zip", "previewUrl" : "output/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/myfile/index.html" }
4. Visiting the previewUrl specified by that response will allow you to preview the converted document in your browser. You may also download the converted output using the download Url. For example, you may do so using the following cURL request:
curl http://localhost:8080/microservice-example/output/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/myfile.zip -LO
Note: -L is used to follow any redirects, and -O is to download the file as it is named, in this case, "myfile.zip", in the current directory. If you want to save the file with a specific name, you can use -o followed by the desired filename. For example:
curl http://localhost:8080/microservice-example/output/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/myfile.zip -Lo "output.zip"
The API.md found here describes the API in more detail in raw request language.