Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

643
Vistas
Upload file (image) from local machine using shopify-api-node

I am trying to upload local images to a Shopify product via node.js and shopify-api-node.

This is the part of the code, where I am uploading the images.

product.images.forEach(async image => {
  Logger.toFile("product.image", image);
  try {
    await this._api.productImage.create(shopifyProduct.id, {
      src: image.src
    });
  } catch (error) {
    Logger.error("Error uploading images.");
    this._handleErrors(error);
  }
})

If I use an external URL for image.src, everything works just fine.

Here is the logger with working external URL:

[2022-02-01 16:44:38 UTC][Products] product.image {
  src: 'https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Image_created_with_a_mobile_phone.png/220px-Image_created_with_a_mobile_phone.png',
  position: 1
}

And the not working local src:

product.image {
  src: '/Users/radoslav/Server/projects/tmp/pics/264-426.png',
  position: 1
}

The path is correct and the image 264-426.png exists.

Any suggestions, what I am doing wrong, or is it possible to upload an image to Shopify from a local link?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You are trying to upload an image from a local relative path which is wrong at the moment.

But I'm not sure if the API handles local images with the proper path and even if you use absolute path.

The best approach will be to read the image with Node.js and convert it to Base64 and pass it that way. You can refer to the docs here: https://shopify.dev/api/admin-rest/2021-07/resources/product-image#[post]/admin/api/2021-07/products/{product_id}/images.json

In addition please note that async/await doesn't work in a forEach function. So at the moment you are stacking all the uploads at the same time and the API will not be happy.

PS: Give my regards to Zoro/Marto & Evgeni. ;)

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda