Skip to content

Attribute API & Images Upload API #3

Answered by logeshswell
JanikHalder asked this question in Help
Discussion options

You must be logged in to vote

@JanikHalder Please find the steps to upload images in Swell and associate to a product or any of the swell components.

  1. Upload images to Swell files directory.
const swell = require('swell-node').init('store-id', 'secret-key');
let fileData = {
  filename: 'filename.png',
  content_type: 'image/png',
  data: {
    $binary: '<imageDataInBase64>'
  }
}
const fileResponse = await swell.post(`/:files`, fileData);
  1. Associate image file to a product.
await swell.put('/products/<product_id>', {
  images: [
    { file: fileResponse }
  ]
});

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@JanikHalder
Comment options

@jezzzm
Comment options

Answer selected by logeshswell
Comment options

You must be logged in to vote
2 replies
@JanikHalder
Comment options

@logeshswell
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
3 participants