unoconv (File Conversion)
Setting up and using unoconv as a Xano microservice
Last updated
Setting up and using unoconv as a Xano microservice
Last updated
Unoconv documentation: https://github.com/alphakevin/unoconv-server
Docker Hub link: https://hub.docker.com/r/alphakevin/unoconv-server
In this example, we will install the unoconv service as a microservice in Xano. This service will allow you to facilitate file conversions right alongside your Xano instance.
Access the Microservice panel as shown below.
Click "+Add" to add a new deployment.
Enter the settings as described below. "Your choice" indicates you can specify these values to be whatever you would like. Please note that some of these other values can be modified based on your needs. The values that should remain static are marked in bold.
Name
Your choice
Replicas
Your choice
Docker Config
public repo
Strategy
RollingUpdate
Name
Your choice
Docker Image
alphakevin/unoconv-server
Container Port
4000
Service Port
80
Environment Variable: HOSTNAME
0.0.0.0
Environment Variable: PORT
4000 (the same as Container Port)
Resources: Min / Max CPU
Recommended: 250m / 1000m
Resources: Min / Max RAM
Recommended: 256Mi / 256Mi
Once you have completed your configuration, click "Add", and then "Update & Deploy". Deployment can take a few minutes based on the Docker image used, the complexity of the configuration, and the current state of your Xano instance.
You will see the message below once deployment is complete.
Please see the service documentation for a breakdown of all options available. Below is a basic file conversion request.
Add a File Resource input. This will be where we provide the file to convert.
Click the + sign on the function stack and add a Microservice Request function. The values below are provided as an example in which we are converting a file to the PNG image format, assuming we have named our service 'converter' and used port 80.
host
converter:80
path
/convert/format/png/output/test.png png - The format we are converting to test.png - The filename of the converted file
method
POST
params
OBJECT {} with a set filter ...path: file ...value: the file resource input
headers
ARRAY [] with a push filter ...Content-Type: multipart/form-data
timeout
60, based on your needs
This should provide you with a successfully converted file in the response.
Use a Create Variable, referencing the contents of the microservice request as shown below, to extract the filename.
Use a Create File Resource step to initialize the converted file with Xano.
Finally, use a Create Image Metadata function to create metadata for the converted image. If you are not working with images, use Create Attachment Metadata instead, or whatever is most appropriate for your use case.
This will allow you to add the converted image back to a Xano database table, and provide you with a direct path to access the converted file. Please see our Content Upload documentation for further possibilities when working with files in the function stack.