Send a File or URL
Reference documentation on sending files or URLs for processing using Mindee client libraries.
Requirements
You'll need to have your Mindee client configured correctly as described in the Configure the Client section.
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 as query parameters: username+password or token. For example, Amazon S3 signed URLs will work.
Contents must be a binary file (raw bytes, not base64-encoded).
File contents cannot be encrypted, PDFs must not be password protected.
The Mindee server will not follow redirections (HTTP 3xx).
Initialize the URL
Use the URLInputSource
class.
from mindee 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.
You can send either using polling or webhooks.
Send with Polling
input_source
is any valid input source, one of:
a local source created in Load and Adjust a File
a remote source created in Use an URL
The mindee_client
and inference_params
are created in Configure the Client.
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)
Send with Webhook
Make sure your webhook is configured as detailed here: Webhook Configuration.
input_source
is any valid input source, one of:
a local source created in Load and Adjust a File
a remote source created in Use an URL
The mindee_client
as created in Initialize the Mindee Client.
The inference_params
as created in 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 Response section for details on the next step.
Last updated
Was this helpful?