Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
config.forge.scope,
true);
if (token.getForgeCredentials() === undefined) {
res.status(401).end();
return;
}
var parentFolderHref = req.body.parentFolder;
var folderName = encoder.htmlDecode(req.body.folderName);
var params = parentFolderHref.split('/');
var projectId = params[params.length - 3];
var parentFolderId = params[params.length - 1];
var folders = new forgeSDK.FoldersApi();
folders.getFolderContents(projectId, parentFolderId, {}, forge3legged, token.getForgeCredentials())
.then(function (folderContents) {
for (var f in folderContents.body.data) {
var item = folderContents.body.data[f];
if (item.type === 'folders' && item.attributes.displayName === folderName) {
res.json({folderId: item.links.self.href});
return;
}
}
if (projectId.indexOf('b.') > -1) {
// BIM 360 Docs project
var createFolder = {
url: 'https://developer.api.autodesk.com/data/v1/projects/' + projectId + '/commands',
method: 'POST',
headers: {
function getFolderContents(projectId, folderId, oauthClient, credentials, res) {
var folders = new forgeSDK.FoldersApi();
folders.getFolderContents(projectId, folderId, {}, oauthClient, credentials)
.then(function (folderContents) {
var folderItemsForTree = [];
folderContents.body.data.forEach(function (item) {
if (item.attributes.extension.type.indexOf('File') == -1
&& item.attributes.extension.type.indexOf('Folder') == -1
&& item.attributes.extension.type.indexOf('C4RModel') == -1) return;
var displayName = item.attributes.name == null ? item.attributes.displayName : item.attributes.name;
var itemType = (unsupported.indexOf(item.attributes.createUserName) == -1 ? item.type : 'unsupported');
if (displayName !== '') { // BIM 360 Items with no displayName also don't have storage, so not file to transfer
folderItemsForTree.push(prepareItemForTree(
item.links.self.href,
displayName,
itemType,
(itemType !== 'unsupported')
async function getFolderContents(projectId, folderId, oauthClient, credentials, res) {
const folders = new FoldersApi();
const contents = await folders.getFolderContents(projectId, folderId, {}, oauthClient, credentials);
const treeNodes = contents.body.data.map((item) => {
var name = (item.attributes.name == null ? item.attributes.displayName : item.attributes.name);
if (name !== '') { // BIM 360 Items with no displayName also don't have storage, so not file to transfer
return createTreeNode(
item.links.self.href,
name,
item.type,
true
);
} else {
return null;
}
});
res.json(treeNodes.filter(node => node !== null));
}
async function getFolderContents(projectId, folderId, oauthClient, credentials, res) {
const folders = new FoldersApi();
const contents = await folders.getFolderContents(projectId, folderId, {}, oauthClient, credentials);
const treeNodes = contents.body.data.map((item) => {
var name = (item.attributes.displayName !== null ? item.attributes.displayName : item.attributes.name);
if (name !== '') { // BIM 360 Items with no displayName also don't have storage, so not file to transfer
return createTreeNode(
item.links.self.href,
name,
item.type,
true
);
} else {
return null;
}
});
res.json(treeNodes.filter(node => node !== null));
}
function getFolderContents(projectId, folderId, tokenSession, res) {
var folders = new forgeSDK.FoldersApi();
folders.getFolderContents(projectId, folderId, {}, tokenSession.getInternalOAuth(), tokenSession.getInternalCredentials())
.then(function (folderContents) {
var folderItemsForTree = [];
folderContents.body.data.forEach(function (item) {
var displayName = item.attributes.displayName == null ? item.attributes.name : item.attributes.displayName;
if (displayName !== '') { // BIM 360 Items with no displayName also don't have storage, so not file to transfer
folderItemsForTree.push(prepareItemForTree(
item.links.self.href,
displayName,
item.type,
true
));
}
});
res.json(folderItemsForTree);
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()
}
function getFolderContents(projectId, folderId, tokenSession, res) {
var folders = new forgeSDK.FoldersApi();
folders.getFolderContents(projectId, folderId, {}, tokenSession.getInternalOAuth(), tokenSession.getInternalCredentials())
.then(function (folderContents) {
var folderItemsForTree = [];
folderContents.body.data.forEach(function (item) {
if (item.attributes.extension.type.indexOf('File') == -1
&& item.attributes.extension.type.indexOf('Folder') == -1
&& item.attributes.extension.type.indexOf('C4RModel') == -1) return;
var name = 'N/A';
if (item.attributes.displayName !== '') name = item.attributes.displayName;
else if (item.attributes.extension.data.sourceFileName !== null) name = item.attributes.extension.data.sourceFileName;
folderItemsForTree.push(prepareItemForTree(
item.links.self.href,
name,
item.type,
true
));