developerforce / Force.com-JavaScript-REST-Toolkit

ForceTK - a minimal Force.com REST API for JavaScript apps
BSD 3-Clause "New" or "Revised" License
315 stars 175 forks source link

One extra character in file body after upload using the createBlob() function in forceTK.js #99

Open gpervukhin opened 4 years ago

gpervukhin commented 4 years ago

DESCRIPTION: If we try to upload a new ContentVersion using the createBlob() function in forceTK.js, then an uploaded file will have one extra byte at the end of content body. It will be a "new line" character (LF).

As a result, some uploaded files get corrupted and cannot be recognized by programs if we download them again. For example, MS Excel and MS Word say that such files are incorrect and suggest to fix the issues in format.

SOLUTION: The issue is in the blob() function (line #293). It adds "\n\n" sequence between payload and final boundary, but only one "\n" is needed.