Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

644
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda