If you use the Nextmv CLI or Python SDK, you do not need to worry about large payloads. They handle the complete run workflow for you.
When submitting a new run and retrieving the run's results, there are size limits to consider for the payload: 5MB for the input and output of a run.
You can use this large payloads workflow to handle bigger sizes. When using this alternative, note that:
- There is a maximum limit of 500MB when uploading a file.
- There is a maximum limit of 100MB when downloading a file.
To achieve this, you can use one of these interfaces:
To work with large payloads, follow these steps:
Python SDK
When using the Python SDK, large payloads are handled for you. Consider the following example:
The size of the input is automatically detected and the large payload workflow is used when necessary. We also handle polling with exponential backoff and jitter for you.
If you want to handle large payloads manually, we provide the methods for you to do so. Here is an example of how to handle large payloads manually:
Note that the output returned in the final step is the native output of your application, and not the JSON
response of the run result endpoint.
Cloud API
When using the Cloud API, you must handle large payloads manually. Here are the steps you need to follow.
1. Request a presigned URL
Request a presigned URL to upload your large input file to.
Retrieve unique upload URL and ID.
Retrieve a unique URL and ID for uploading run input (for large input files).
The result will contain an upload_id
and upload_url
.
This returned upload URL will only last for 15 minutes. If it expires, simply request a new one and take note of the new upload ID.
You can export the upload_id
and upload_url
to variables:
2. Upload the large input
Upload your input using the upload_url
that was obtained before. We use --data-binary
here to make sure curl sends the content of the file unaltered.
An empty response means the upload was successful. Note that this may take a moment depending on the size of the input file.
3. Start the run
Once the upload has completed, you can start a new run with the large input using the upload_id
from a previous step. This upload_id
is sent in the body of the run request in place of the input. The result contains the run_id
to retrieve the run results.
New application run.
Create new application run.
You should receive a run_id
like normal as a response.
4. Get the run result
To get the result of your run, you use the same endpoint as with a standard run but with the appended query parameter ?format=url
. This will return a standard run result payload but instead of the run output included in the returned JSON, in its place will be a URL to download the output file.
Get run result.
Get the result of a run.
Note that the ?format=url
query parameter can be used regardless of your output size.
The output.url
key contains the presigned URL to download the output.
Finally, you can download the output using the presigned URL: