Upload a reference image
Upload via presign
Upload an image up to 25 MB and get a URL back, for use as a reference image.
https://api.sangtao.ai/v2/images/presignImages uploaded here are kept only temporarily, as reference images (referenceImages) for the image you create right after, and are deleted automatically after 1 day. To keep a file for good and reuse it, use the asset library. Files up to 25 MB, in two calls: get a link, then PUT the file to it.
Headers
X-Api-KeystringrequiredYour API key. Create one on the API Key page in your account.
Content-Typestringrequiredapplication/json
Request
fileNamestringrequiredAny name you like — only the extension matters, since it decides how the file is served back.
contentTypestringrequiredThe image’s type. Any other is refused with 400 UNSUPPORTED_FILE_TYPE.
Available options:image/pngimage/jpegimage/webp
Response
uploadUrlstringWhere to send the file. The signature is in the URL, so that request needs no X-Api-Key.
methodstringThe method for that request: "PUT".
headersobjectSend exactly these headers with the file — Content-Type, and x-ms-blob-type when it is there. Read them from here rather than writing them in your code.
urlstringThe image’s address once uploaded: pass it as referenceImages.
expiresInnumberSeconds until uploadUrl stops working (600). Upload as soon as you have it.
fileKeystringThe file’s key on our side. Not needed to create an image.
/images/presigncurl -X POST \
https://api.sangtao.ai/v2/images/presign \
-H "X-Api-Key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"fileName": "design.png",
"contentType": "image/png"
}'
# Then send the file to data.uploadUrl with data.method,
# adding every header in data.headers{
"success": true,
"data": {
"uploadUrl": "https://…/ref-uploads/…/745c53c6-….png?sv=…&sig=…",
"method": "PUT",
"headers": {
"Content-Type": "image/png",
"x-ms-blob-type": "BlockBlob"
},
"url": "https://cdn.sangtao.ai/ref-uploads/…/745c53c6-….png",
"expiresIn": 600,
"fileKey": "284c42a4-…/745c53c6-….png"
},
"error": null,
"errorCode": null
}/images/presigncurl -X POST \
https://api.sangtao.ai/v2/images/presign \
-H "X-Api-Key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"fileName": "design.png",
"contentType": "image/png"
}'
# Then send the file to data.uploadUrl with data.method,
# adding every header in data.headers{
"success": true,
"data": {
"uploadUrl": "https://…/ref-uploads/…/745c53c6-….png?sv=…&sig=…",
"method": "PUT",
"headers": {
"Content-Type": "image/png",
"x-ms-blob-type": "BlockBlob"
},
"url": "https://cdn.sangtao.ai/ref-uploads/…/745c53c6-….png",
"expiresIn": 600,
"fileKey": "284c42a4-…/745c53c6-….png"
},
"error": null,
"errorCode": null
}