Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function getNewCreatedStorageInfo(projectId, folderId, fileName, oauth_client, oauth_token) {
// create body for Post Storage request
let createStorageBody = createBodyOfPostStorage(folderId, fileName);
const project = new ProjectsApi();
let storage = await project.postStorage(projectId, createStorageBody, oauth_client, oauth_token);
if (storage === null || storage.statusCode !== 201) {
console.log('failed to create a storage.');
return null;
}
// setup the url of the new storage
const strList = storage.body.data.id.split('/');
if (strList.length !== 2) {
console.log('storage id is not correct');
return null;
}
const storageUrl = "https://developer.api.autodesk.com/oss/v2/buckets/" + AUTODESK_HUB_BUCKET_KEY + "/objects/" + strList[1];
return {
"StorageId": storage.body.data.id,
"StorageUrl": storageUrl
function getFolders(hubId, projectId, tokenSession, res) {
// if the caller is a project, then show folders
var projects = new forgeSDK.ProjectsApi();
projects.getProjectTopFolders(hubId, projectId, tokenSession.getInternalOAuth(), tokenSession.getInternalCredentials())
.then(function (topFolders) {
var folderItemsForTree = [];
topFolders.body.data.forEach(function (item) {
folderItemsForTree.push(prepareItemForTree(
item.links.self.href,
item.attributes.displayName == null ? item.attributes.name : item.attributes.displayName,
item.type,
true
))
});
res.json(folderItemsForTree);
})
.catch(function (error) {
console.log(error);
res.status(500).end();
function getFolders(hubId, projectId, tokenSession, res) {
// if the caller is a project, then show folders
var projects = new forgeSDK.ProjectsApi();
projects.getProjectTopFolders(hubId, projectId, tokenSession.getInternalOAuth(), tokenSession.getInternalCredentials())
.then(function (topFolders) {
var folderItemsForTree = [];
topFolders.body.data.forEach(function (item) {
folderItemsForTree.push(prepareItemForTree(
item.links.self.href,
item.attributes.displayName == null ? item.attributes.name : item.attributes.displayName,
item.type,
true
))
});
res.json(folderItemsForTree);
})
.catch(function (error) {
console.log(error);
res.status(500).end();
function getProjects(hubId, tokenSession, res) {
// if the caller is a hub, then show projects
var projects = new forgeSDK.ProjectsApi();
//console.log(tokenSession.getInternalOAuth());
//console.log(tokenSession.getInternalCredentials());
projects.getHubProjects(hubId, {},
tokenSession.getInternalOAuth(), tokenSession.getInternalCredentials())
.then(function (projects) {
var projectsForTree = [];
projects.body.data.forEach(function (project) {
var projectType = 'projects';
switch (project.attributes.extension.type) {
case 'projects:autodesk.core:Project':
projectType = 'a360projects';
break;
case 'projects:autodesk.bim360:Project':
projectType = 'bim360projects';
function getFolders(hubId, projectId, oauthClient, credentials, res) {
var projects = new forgeSDK.ProjectsApi();
projects.getProjectTopFolders(hubId, projectId, oauthClient, credentials)
.then(function (topFolders) {
var folderItemsForTree = [];
topFolders.body.data.forEach(function (item) {
folderItemsForTree.push(prepareItemForTree(
item.links.self.href,
item.attributes.displayName == null ? item.attributes.name : item.attributes.displayName,
item.type,
true
))
});
res.json(folderItemsForTree);
})
.catch(function (error) {
console.log(error);
res.status(500).end();
.then((oa3Legged) => {
let projects = new ForgeAPI.ProjectsApi();
return (projects.getHubProjects(hubId, {}, oa3Legged, oa3Legged.credentials));
})
.then((projects) => {
constructor(config) {
super(config)
this._projectsAPI = new Forge.ProjectsApi()
this._versionsAPI = new Forge.VersionsApi()
this._foldersAPI = new Forge.FoldersApi()
this._itemsAPI = new Forge.ItemsApi()
this._hubsAPI = new Forge.HubsApi()
}
.then((oa3Legged) => {
let projects = new ForgeAPI.ProjectsApi();
return (projects.getProjectTopFolders(hubId, projectId, oa3Legged, oa3Legged.credentials));
})
.then((folders) => {
async function getProjects(hubId, oauthClient, credentials, res) {
const projects = new ProjectsApi();
const data = await projects.getHubProjects(hubId, {}, oauthClient, credentials);
res.json(data.body.data.map((project) => {
let projectType = 'projects';
switch (project.attributes.extension.type) {
case 'projects:autodesk.core:Project':
projectType = 'a360projects';
break;
case 'projects:autodesk.bim360:Project':
projectType = 'bim360projects';
break;
}
return createTreeNode(
project.links.self.href,
project.attributes.name,
projectType,
true