Skip to main content
Limina supports scanning a wide range of different file types for PII and creating de-identified or redacted copies. Limina’s supported entity types work across each file type, with localized variants of different PII (Personally Identifiable Information), PHI (Protected Health Information), and PCI (Payment Card Industry) entities detected. Our Supported Languages and Supported Entity Types page provides a more detailed look.

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

The base64 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, the uri 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.
API calls are made by pointing to a file on a mounted drive, an S3 address, or an HTTP URL. When necessary, Limina downloads the file to a local temporary location before processing it. Once the file is processed, its redacted contents are automatically saved at a user-specified location with the .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
Passing a file with no extension or with the wrong extension to the uri endpoint may lead to unexpected behavior.

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
The file is first read into memory so its contents can be encoded, and the encoded contents are then passed to the file processing endpoint. On Linux, this can be done with the base64 shell command. Assuming you have the file sample.pdf saved in the current folder:
This command will redact the file contents and return the redacted document as a base64-encoded string.
An example Python script showing how to process files with Limina’s Python client using the base64 route can be found here.
It is important that the proper MIME type is provided with the base64-encoded string. Failing to pass the proper MIME type may lead to unexpected behavior. Check out the Supported File Types page for proper MIME types.
Check out the API reference for more details on the base64 endpoint.

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.
In addition, the service requires access to a folder where the redacted files will be stored. This is done with the 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
This is an example of a command that mounts a files folder in the admin home folder as input and an output folder as the output location.
Docker Command
Common PitfallMounting a folder to an existing OS or app folder in the container may lead to unexpected behavior.
An example Python script showing how to process files with Limina’s Python client using the URI route can be found here.
Once the container is running with the above command, you can redact files with:
Upon successful completion, the above command will save the redacted file under /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 the PAI_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.
For security reasons, Limina will not follow redirects when an URLs is provided.

Check out the API reference for more details on the uri endpoint.