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.
The contents of a URL cannot be manipulated locally. 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
All Accepted Files may be used, if they adhere to the File Limits.
In addition, 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"
)Use the URLInput class.
const inputSource = new mindee.UrlInput({
url: "https://example.com/file.ext"
});Use the URLInputSource class.
use Mindee\Input\URLInputSource;
$inputSource = new URLInputSource(
url: "https://example.com/file.ext"
);require 'mindee'
input_source = Mindee::Input::Source::URLInputSource.new(
'https://example.com/file.ext'
)Use the URLInputSource class.
import com.mindee.input.URLInputSource;
URLInputSource inputSource = URLInputSource
.builder("https://example.com/file.ext")
.build();Use the URLInputSource class.
var inputSource = new 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
You'll need a 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 were extracted,
# simply print an RST representation of the inference
print(response.inference)The mindeeClient and inferenceParams are created in Configure the Client.
Use the enqueueAndGetInference method:
const response = mindeeClient.enqueueAndGetInference(
inputSource,
inferenceParams
);
// Handle the response Promise
response.then((resp) => {
// To easily test which data were extracted,
// simply print an RST representation of the inference
console.log(resp.inference.toString());
});The $mindeeClient and $inferenceParams are created in Configure the Client.
Use the enqueueAndGetInference method:
$response = $mindeeClient->enqueueAndGetInference(
$inputSource,
$inferenceParams
);
// To easily test which data were extracted,
// simply print an RST representation of the inference
echo strval($response->inference);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 were extracted,
# simply print an RST representation of the inference
puts response.inferenceThe mindeeClient and inferenceParams are created in Configure the Client.
Use the enqueueAndGetInference method:
InferenceResponse response = mindeeClient.enqueueAndGetInference(
inputSource, inferenceParams
);
// To easily test which data were extracted,
// simply print an RST representation of the inference
System.out.println(response.getInference().toString());The mindeeClient and inferenceParams are created in Configure the Client.
Use the EnqueueAndGetInferenceAsync method:
var response = await mindeeClient.EnqueueAndGetInferenceAsync(
inputSource, inferenceParams);
// To easily test which data were extracted,
// simply print an RST representation of the inference
System.Console.WriteLine(response.Inference.ToString());Send with Webhook
You'll need a valid input source, one of:
a local source created in Load and Adjust a File
a remote source created in Use an URL
Make sure your webhook is configured as detailed here: Webhook Configuration.
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.
The mindeeClient as created in Initialize the Mindee Client.
The inferenceParams as created in Webhook Configuration.
Use the enqueueInference method:
const response = mindeeClient.enqueueInference(
inputSource,
inferenceParams
);
// Handle the response Promise
response.then((resp) => {
// You should save the job ID for your records
console.log(resp.job.id);
// If you set an `alias`, you can verify it was taken into account
console.log(resp.job.alias);
});Note: You can use both methods!
First, make sure you've added a webhook ID to the InferenceParameters instance.
Then, call enqueueAndGetInference and handle the promise.
You'll get the response via polling and webhooks will be used as well.
The $mindeeClient as created in Initialize the Mindee Client.
The $inferenceParams as created in Webhook Configuration.
Use the enqueueInference method:
$response = $mindeeClient->enqueueInference(
$inputSource,
$inferenceParams
);
// You should save the job ID for your records
echo strval($response->job->id);
// If you set an `alias`, you can verify it was taken into account
echo strval($response->job->alias);Note: You can also use both methods!
First, make sure you've added a webhook ID to the InferenceParameters instance.
Then, call enqueueAndGetInferenceAsync.
You'll get the response via polling and webhooks will be used as well.
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
puts response.job.id
# If you set an `alias`, you can verify it was taken into account
puts response.job.aliasNote: 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.
The mindeeClient as created in Initialize the Mindee Client.
The inferenceParams as created in Webhook Configuration.
Use the enqueueInference method:
JobResponse response = mindeeClient.enqueueInference(
inputSource, inferenceParams
);
// You should save the job ID for your records
System.out.println(response.getJob().getId());
// If you set an `alias`, you can verify it was taken into account
System.out.println(response.getJob().getAlias());Note: You can use both methods!
First, make sure you've added a webhook ID to the InferenceParameters instance.
Then, call enqueueAndGetInference and handle the promise.
You'll get the response via polling and webhooks will be used as well.
The mindeeClient as created in Initialize the Mindee Client.
The inferenceParams as created in Webhook Configuration.
Use EnqueueInferenceAsync method:
var response = mindeeClient.EnqueueInferenceAsync(
inputSource, inferenceParams
);
// You should save the job ID for your records
System.Console.WriteLine(response.Job.Id);
// If you set an `alias`, you can verify it was taken into account
System.Console.WriteLine(response.Job.Alias);Note: You can also use both methods!
First, make sure you've added a webhook ID to the InferenceParameters instance.
Then, call EnqueueAndGetInferenceAsync.
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?

