Image

Upload Image via Base64 Encoding

0calls
2 credits / call

When you need to process images on the frontend (such as after cropping or applying filters) and upload them directly without traditional forms, this endpoint comes in handy.

Interface Adjustment in Progress

This interface has been taken down due to policy reasons and will not be restored in the short term. Whether it will be restored later and the restoration time will be notified separately.

POST
uapis.cn
/api/v1/image/frombase64
Body
imageData
string
required

Base64 Data URI of the image, must include MIME type header. For example: data:image/png;base64,...

Overview

You just need to send the Base64 encoded string of the image, we will decode it, save it as an image file, and return a publicly accessible URL.

Usage Notes

Important

About imageData Format The imageData string you send must be in complete Base64 Data URI format, which needs to include MIME type information, such as data:image/png;base64,iVBORw0KGgo.... Missing the data:image/...;base64, prefix will cause decoding failure.

Request body

imageData
stringrequired

Base64 Data URI of the image, must include MIME type header. For example: data:image/png;base64,...

Response

200 / OK

Upload successful! Returns the access address of the image.

JSON
{
  // Absolute access URL of the image saved on the server.
  "image_url": "https://uapis.cn/static/uploads/91e42db1c66c0b276abf6234dc50b2eb.png",
  // Operation result description.
  "msg": "success"
}

400 / Bad Request

Request failed. Possible reasons: request body is not valid JSON, missing imageData field, or imageData content is not a valid Base64 Data URI.

JSON
{
  "code": "INVALID_ARGUMENT",
  "details": {},
  "message": "Invalid request body or imageData."
}

500 / Internal Server Error

Internal server error. An unknown error occurred while decoding or saving the image file. Please try again later.

JSON
{
  "code": "INTERNAL_SERVER_ERROR",
  "details": {},
  "message": "Failed to save the image."
}