How can I use the admin API to upload local images to products

Topic summary

Main issue: how to upload local product images via the REST Admin API and what to provide in the “attachment” field.

Key clarification:

  • “Attachment” should contain the image data encoded in Base64 (a text representation of binary data).
  • A reference tool was provided to convert image files to Base64.

Actionable steps:

  • Take the local image file and convert it to a Base64 string.
  • Use that Base64 string as the value of the product image’s “attachment” field in the API request.

Notes:

  • The included screenshot appears illustrative and is not required to understand the solution.

Outcome and status:

  • Clear guidance given on generating the required data format for uploads.
  • No conflicting views; the thread appears resolved with a straightforward solution.
Summarized with AI on January 12. AI used: gpt-5.

We have a requirement to use local images on the product. Due to the high demand, we would like to upload product images using the rest amdin API, but I don’t know how to generate “attachment” data.

Hey @luoooofei

Attachment is a Base64 version of the image. https://base64.guru/converter/encode/image