Send a File or URL

Reference documentation on sending files or URLs for processing using Mindee client libraries.

This is reference documentation. Looking for a quick TL;DR?

  • Take a look at the Integrating Mindee page.

  • Use the search bar above to ask our documentation AI to write code samples for you.

Requirements

You'll need to have your Mindee client configured correctly as described in the Configure the Client page.

Both the Client and the Inference Parameters are required.

Overview

You can send either a local file or an URL to Mindee servers for processing.

The source has no impact on server-side processing nor on the result.

A local file can be manipulated and adjusted before sending, as described in the Adjust the Source File section.

An URL cannot be manipulated locally for obvious reasons, you'll need to download it to the local machine if you wish to adjust the file in any way before sending.

Use a File

You'll need a Local Input Source as described in the Load and Adjust a File section.

Use an URL

You'll need a Remote Input Source as described below.

Requirements

The source URL must adhere to the following rules:

  • Secured using TLS (HTTPS).

  • Publicly available using only the URL, no authentication headers.

  • Authentication may be provided in the URL: username/password or token. For example, Amazon S3 signed URLs will work.

  • Contents must be a binary file (raw bytes, not base64-encoded).

  • No redirections (HTTP 3xx), these will not work.

Initialize the URL

Use the URLInputSource class.

from mindee.input import UrlInputSource

input_source = UrlInputSource(
    "https://example.com/file.ext"
)

Send for Processing

There's no difference between sending a file or an URL, both are considered valid Input Sources.

input_source is any valid input source, one of:

The mindee_client and inference_params are created in Configure the Client.

For polling, use the enqueue_and_get_inference method.

response = mindee_client.enqueue_and_get_inference(
    input_source, inference_params
)

# To easily test which data was extracted,
# simply print an RST representation of the inference
print(response.inference)

For webhooks:

Make sure your webhook is configured as detailed here: Webhook Configuration.

Use the enqueue_inference method:

response = mindee_client.enqueue_inference(
    input_source, inference_params
)

# You should save the job ID for your records
print(response.job.id)

# If you set an `alias`, you can verify it was taken into account
print(response.job.alias)

Note: You can use both methods!

First, make sure you've added a webhook ID to the InferenceParameters instance. Then, call enqueue_and_get_inference . You'll get the response via polling and webhooks will be used as well.

Process the Result

Now that your file or URL has been handled by the Mindee servers, you'll want to process the results and use them in your application.

Head on over to the Process the Result page for details on the next step.

Last updated

Was this helpful?