Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return (new Promise((fulfill, reject) => {
if (!fileurn || !modelurn)
return (reject('Missing the required parameter {urn} when calling getManifest'));
let ModelDerivative = new ForgeAPI.DerivativesApi();
ModelDerivative.apiClient.basePath = 'https://otg.autodesk.com';
ModelDerivative.apiClient.callApi(
'/modeldata/file/' + fileurn + encodeURI(elt), 'GET',
{}, { acmsession: modelurn }, { 'Accept-Encoding': 'gzip, deflate', pragma: 'no-cache' },
{}, null,
[], ['application/json'], null,
this._token, this._token.getCredentials()
)
.then((res) => {
return (utils.gunzip(res.body, true));
})
.then((data) => {
return (utils.writeFile(outFile, data, 'binary', true));
})
.then((data) => {
console.log(' >> ', outFile);
router.get ('/translate/:urn/progress', function (req, res) {
var accessToken =req.query.accessToken ;
var urn =req.params.urn ;
var oAuth2 =new ForgeApis.AuthClientTwoLegged ('', '', config.credentials.scope) ;
oAuth2.setCredentials ({
access_token: accessToken,
type: 'Bearer',
expires_at: 3599,
}) ;
var md = new ForgeApis.DerivativesApi();
md.getManifest (urn, {}, oAuth2, oAuth2.getCredentials ())
.then (function (data) {
var name =_path.basename (Buffer.from (data.body.urn, 'base64').toString ()) ;
if ( data.body.derivatives !== undefined && data.body.derivatives.length > 0 && data.body.derivatives [0].hasOwnProperty ('name') )
name =data.body.derivatives [0].name ;
res.json ({
status: data.body.status,
progress: data.body.progress,
urn: data.body.urn,
name: name
}).end () ;
console.log ('Request: ' + data.body.status + ' (' + data.body.progress + ')') ;
})
.catch (function (error) {
res.status (404).end () ;
}) ;
router.get('/properties', function (req, res) {
var derivatives = new forgeSDK.DerivativesApi();
var tokenSession = new token(req.session);
derivatives.getModelviewProperties(req.query.urn, req.query.guid, {}, tokenSession.getInternalOAuth(), tokenSession.getInternalCredentials())
.then(function (data) {
res.json(data.body);
})
.catch(function (error) {
res.status(error.statusCode).end(error.statusMessage);
});
});
return (new Promise (function (fulfill, reject) {
let accepted = [ 'application/octet-stream', 'image/png', 'text/html', 'text/css', 'text/javascript', 'application/json' ] ;
let ModelDerivative =new ForgeAPI.DerivativesApi () ;
ModelDerivative.apiClient.callApi (
uri, 'GET',
{}, {}, {},
{}, null,
[], accepted, null,
//forgeToken.RW, forgeToken.RW.getCredentials ()
null, null
)
//.pipe (zlib.createGunzip ())
.then ((response) => {
let body =response.body ;
if ( ['gzip', 'deflate'].indexOf (response.headers ['content-encoding']) !== -1 )
body =zlib.gunzipSync (response.body) ;
if ( response.headers ['content-type'] === 'text/javascript'
|| response.headers ['content-type'] === 'text/css'
router.get('/metadatas/:urn', function (req, res) {
var derivatives = new forgeSDK.DerivativesApi();
var tokenSession = new token(req.session);
derivatives.getMetadata(req.params.urn, {}, tokenSession.getInternalOAuth(), tokenSession.getInternalCredentials())
.then(function (data) {
res.json(data.body);
})
.catch(function (error) {
res.status(error.statusCode).end(error.statusMessage);
});
});
.then((_oa2legged) => {
oa2legged = _oa2legged;
let urn = Forge_MD.createOSSURN(bucketKey, filename, true);
let md = new ForgeAPI.DerivativesApi();
return (md.getManifest(urn, {}, oa2legged, oa2legged.getCredentials()));
})
.then((manifest) => {
.then((_jobs) => {
if (_jobs.output.formats.length === 0)
throw new Error('Please specify an output format');
let md = new ForgeAPI.DerivativesApi();
return (md.translate(_jobs, { xAdsForce: force }, oa2legged, oa2legged.getCredentials()));
})
.then((response) => {
downloadItem (urn) {
if (urn === undefined || urn === null)
return (Promise.reject('Missing the required parameter {urn} when calling getManifest'));
let ModelDerivative = new ForgeAPI.DerivativesApi();
return (ModelDerivative.apiClient.callApi(
'/derivativeservice/v2/derivatives/{urn}', 'GET',
{ 'urn': urn }, {}, { 'Accept-Encoding': 'gzip, deflate' },
{}, null,
[], [], null,
this._token, this._token.getCredentials()
));
}
.then (function (data) {
//if ( !data.hasOwnProperty ('urn') )
// throw new Error ('No URN') ;
var urn =utils.safeBase64encode (data.objectId) ;
var ModelDerivative =new ForgeSDK.DerivativesApi () ;
return (ModelDerivative.getManifest (urn, {}, forgeToken.RW, forgeToken.RW.getCredentials ())) ;
})
.then (function (manifest) {