Connect with one of our privacy experts to run this code.
How Does It Work?
Limina’s file processing support uses unified endpoints that work with either base64-encoded files or URIs:/process/files/base64 and /process/files/uri.
Base64
Thebase64 endpoint is the recommended way to process files for most users, as there is no need to mount a volume into the container or ensure that permissions are set correctly. To use the base64 endpoint, you first need to read the file into memory, encode its contents with base64, and send it to the endpoint. You also need to pass the MIME type of the file as a hint to the file processing pipeline. The Supported File Types page details extensions and MIME types for both endpoints.
URI
Available on the container only, theuri endpoint is suitable for larger data volumes and has the following advantages over the base64 endpoint:
- No overhead of base64 encoding.
- No need to read the file into memory first.
- The processed file is saved automatically by the container.
.redacted suffix added to the original name. For example, the uri endpoint accesses the file /some/path/my-doc.pdf, redacts it, and creates a file my-doc.redacted.pdf with the redacted contents at the location specified by the user. When using the uri endpoint, the file extension is used to determine the file type.
A mounted drive can be connected to remote object storage or NAS. For instructions on how to connect a mounted drive to S3, please follow the guide here: Using remote storage
Diving Deeper
Processing files with the base64 endpoint
When using the /process/files/base64 endpoint, there is no need to mount a folder into the container.
Docker Command
base64 shell command. Assuming you have the file sample.pdf saved in the current folder:
An example Python script showing how to process files with Limina’s Python client using the base64 route can be found here.
Processing files with the uri endpoint
There are a few approaches to processing files with the /process/files/uri endpoint:
- mount a volume into the Limina container and specify paths to that mounted volume as URIs;
- use S3 paths, in which case you will need to provide AWS credentials;
- use HTTP(S) URLs, in which case you will have to create a list of allowed domains from which Limina can safely download files. This approach also works with AWS presigned S3 URLs.
PAI_OUTPUT_FILE_DIR environment variable. This variable must point to an output folder (possibly the same as the input folder mentioned above) that is mounted into the container or an S3 bucket.
Processing files in a mounted folder
This is an example of a command to start the Limina container with mounted input and output folders.Docker Command
files folder in the admin home folder as input and an output folder as the output location.
Docker Command
An example Python script showing how to process files with Limina’s Python client using the URI route can be found here.
/home/admin/files/output/sample.redacted.pdf.
For more information on processing files as a non-root user, please visit here.
Processing files from S3
For details on how to process files from S3, or to store redacted contents in S3, see Using remote storage.Processing files via HTTP(S)
You can also specify a file to process with a URL. This includes short-lived URLs like AWS S3 presigned URLs. When doing so, there is no need to mount an input folder. However, it is still necessary to specify an output folder via thePAI_OUTPUT_FILE_DIR environment variable.
When processing files from URLs, it is necessary to whitelist the domains from which these files will be downloaded using the PAI_ALLOWED_HTTP_DOMAINS environment variable. For example, if you plan on using AWS S3 presigned URLs, the domain amazonaws.com (or any other domain that your presigned URLs may contain) should be added to the list in PAI_ALLOWED_HTTP_DOMAINS. The list of allowed domains should be passed at container startup.
Check out the API reference for more details on the uri endpoint.