Autodesk-Forge / forge-api-nodejs-client

Forge Node.js SDK: Provides Node.js SDK to help you easily integrate Forge REST APIs into the application
Apache License 2.0
121 stars 87 forks source link

getDerivativeManifest is not returning the file correctly #117

Open HunterZhou97 opened 5 months ago

HunterZhou97 commented 5 months ago

Hello 👋

If I am not mistaken, the "getDerivativeManifest" function (from DerivativesAPI) is currently deprecated. However, currently if the function is called within a NodeJS project, the function returns a binary string (when previously it returned a Buffer). Causing the "file" to not be manageable correctly within a NodeJS project (Eg. when you download a PDF from a derivative and you want to save the file on the computer with fs, the saved file will appear blank or with an error).

image

Doing my research, it appears this occurred when changes were made to the "callApi" function (in the src/ApiClient.js file):

So, to solve this problem, you only need to add the "responseType" prop when the getDerivativeManifest() function calls the callApi() function, and the value of "responseType" must be "arraybuffer" (this so that Axios can interpret that the request response is a Buffer).