bhushankummar / amazon-mws

Amazon MWS NodeJS Wrapper
MIT License
197 stars 78 forks source link

How to setup Content-type on SubmitFeed? #77

Closed dropbug closed 5 years ago

dropbug commented 5 years ago

I am uploading a product to FR using a SubmitFeed with FlatFile,it works.Great! But,I found some garbled text, like " santé". Actually,it is "santé". This is my code: image

It may be the reason for content-type,i want to setup content-type="text/tab-separated-values; charset=iso-8859-1" try fix it.

dropbug commented 5 years ago

I tried this way,it doesn`t work. Help me,please~ image

bhushankummar commented 5 years ago

@dropbug Check these examples. Maybe it can help you to control over charset.

https://github.com/bhushankumarl/amazon-mws/blob/master/examples/javaScript/feeds/getFeedSubmissionResultRaw.js

https://github.com/bhushankumarl/amazon-mws/blob/master/examples/javaScript/feeds/getFeedSubmissionResultCharset.js

luxlux commented 5 years ago

I just came across this package the last minutes, and took a look to the issues feed, to see if it seems to be reliable. So unfortunately i can't tell about a solution which is possibly built in to this package.

But anyhow, in former times i still spend i lot of time with problems around latin1 and selling on amazon.

  1. So we write our flat file product descriptions in Google Docs. When we download the data as .TSV file (tab seperated CSV), we always need to convert this file manually with open it in a native text editor and convert the charset there into the needed latin1 encoding (we use CODA for this on mac). If we upload the file without this conversion, we have the same problem like described by you. I never built a programatic solution for this, because in this case this had to be a solution for google docs, which i simply was to lazy to checkout.

  2. But i nevertheless have a programatic solution. We do our order processing based on javascript and the amazon API. Javascript internally does everything in UTF-8. But to get parcel labels from our shipping providers we need to upload the address data in latin1 encoding.

I asked 2015 for a solution on stack overflow, i got none. Possibly because a native javascript solution just evolved in these times. One year later there was something useable for a solution. So i answered my own question.

I guess this solution should work also in your case to do a conversion of your feed text content, which you want to upload. Look for the section "UPDATE 08-Feb-2016" in my answer.

Do the encoding with var encoded = new TextEncoder("windows-1252",{ NONSTANDARD_allowLegacyEncoding: true }).encode(text); BUT this only works after you have included the mentioned polyfill version of TextEncoder, which i mentioned in the post. Because the 'TextEncoder' which is build in in chrome, does only support latin1 to utf-8, but not the other direction. (Seems to be a it of politics, to get rid of these old encodings ...)

PLEASE post it here, if you found a solution for your problem, to help others with the same problem!

bhushankummar commented 5 years ago

@dropbug

76 Added feature to allow a user to change the content type.

bhushankummar commented 5 years ago

@dropbug The new version has been released with a fixed and new feature. https://github.com/bhushankumarl/amazon-mws/releases/tag/v0.0.24