Upload media (OSS)
Vmake Labs tools take a publicly readable media URL as input. The recommended approach is to exchange temporary Aliyun OSS credentials from the token policy API, upload with the official OSS SDK, and use the resulting URL as the tool input.
Step 1: Get temporary credentials
Example response (key parts only):
Read it in this order:
data.mtai.upload.order[0]gives the cloud name (currentlyoss).data.mtai.upload[cloud]is the storage policy used for the OSS upload.- If the config sets both
token_policy_types.uploadandtoken_policy_types.ai, request the upload and AI policies with their respective types. data.mtai.api.order[0]gives the tool cloud, anddata.mtai.api[cloud]is the AI policy used to submit and poll tasks.
You can reuse the AI policy within its
ttl. Fetch a new storage policy before every upload.
cURL example
Continuing from the config and region_name variables in Get config, get the AI policy and save it to ai.
The example skips the OSS upload and uses an image you are authorized to use that is readable at a public URL. To use a local image, upload it as in step 2 and use policy.data instead.
Step 2: Upload with temporary OSS credentials
Key points:
- Normalize
endpointtohttps://<host>and drop the path. - For OSS signing, parse
regionfrom the endpoint host first. Usepolicy.regionwhen the host does not contain one. - Use the STS triple in
credentialsas static credentials. - Take
bucketandkeyforPutObjectRequestdirectly frompolicy. - After a successful upload, the tool input URL is
policy.data.
Python example (Aliyun OSS SDK v2):
Remote media
If your media already has a public URL:
- If the URL is stable and has no strict access control, use it directly as the tool input.
- If the URL requires authentication, expires quickly, or is on a private network, download it to disk or memory first and upload it through the OSS flow above so the tool can read it.