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

DerivativesApi().getThumbnail() encodes the result to string #93

Closed adamenagy closed 11 months ago

adamenagy commented 1 year ago

DerivativesApi().getThumbnail() encodes the result (data.body) to a string instead of keeping it as Buffer so that it could be passed down to the browser as a source for e.g. in

adamenagy commented 1 year ago

e.g. to get back Buffer instead of string using the request npm package in nodejs I need to pass in encoding: null

let r = require("request");
    r.get({
      method: "GET",
      uri: `https://developer.api.autodesk.com/modelderivative/v2/designdata/${req.params.versionId64}/thumbnail`,
      encoding: null,
      headers: {
        "Authorization": `Bearer ${tokenSession.getInternalCredentials().access_token}` 
      }
    }, (err, httpResponse, body) => {
      res.writeHead(200, {'Content-Type': 'image/png'});
      res.end(body); 
    })