Convert Image from base64 to Image
Converts a base64 image sent from the frontend into a hosted image and returns its URL.
| Method | GET |
| Path | /api/v1/baseToUrl |
| Full URL | https://backend.4dnum.com/api/v1/baseToUrl |
Method and path caveats
The source document specifies GET for this endpoint, and gives it the same
path as Check the image is exist or not. A base64 image
payload will not fit in a URL for anything but a very small picture, so in
practice this call is likely POST with a JSON body. Confirm the method and
path with your PIC before implementing. The parameters below are documented as
written.
Request
| Attribute | Type | Mandatory | Example | Description |
|---|---|---|---|---|
mode | String | Yes | dark | dark = dark mode, light = light mode. |
date | String | Yes | 20240228 | Draw date, YYYYMMDD. No dashes. |
image | String | Yes | iVBORw0KG... | The image in base64 format. |
type | String | Yes | Special_CashSweep | Company full name, not the abbreviation. |
language | String | Yes | en | en = English, cn = Chinese, my = Malay. |
Response
| Attribute | Type | Example | Description |
|---|---|---|---|
s3_url | String | https://backend.4dnum.com/DARK20240228Special_CashSweepEN.png | URL of the stored image. |
success | Boolean | true | Whether the conversion succeeded. |
The generated filename follows the pattern
{MODE}{YYYYMMDD}{Company_Full_Name}{LANGUAGE}.png, with MODE and LANGUAGE
upper-cased — for example DARK20240228Special_CashSweepEN.png.
Example
{
"s3_url": "https://backend.4dnum.com/DARK20240228Special_CashSweepEN.png",
"success": true
}
Notes
- Always call Check the image is exist or not first. If
exististrue, skip the conversion — the image is already hosted. - Strip the
data:image/png;base64,prefix from a canvas export before sending, unless your PIC confirms the backend accepts the full data URI.