Skip to main content

Convert Image from base64 to Image

Converts a base64 image sent from the frontend into a hosted image and returns its URL.

MethodGET
Path/api/v1/baseToUrl
Full URLhttps://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

AttributeTypeMandatoryExampleDescription
modeStringYesdarkdark = dark mode, light = light mode.
dateStringYes20240228Draw date, YYYYMMDD. No dashes.
imageStringYesiVBORw0KG...The image in base64 format.
typeStringYesSpecial_CashSweepCompany full name, not the abbreviation.
languageStringYesenen = English, cn = Chinese, my = Malay.

Response

AttributeTypeExampleDescription
s3_urlStringhttps://backend.4dnum.com/DARK20240228Special_CashSweepEN.pngURL of the stored image.
successBooleantrueWhether 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 exist is true, 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.