How to use the forge-apis.FoldersApi function in forge-apis

To help you get started, we’ve selected a few forge-apis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Autodesk-Forge / bim360appstore-data.management-nodejs-transfer.storage / server / forge / integration.js View on Github external
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: {
github Autodesk-Forge / bim360appstore-data.management-nodejs-transfer.storage / server / forge / tree.js View on Github external
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')
github Autodesk-Forge / learn.forge.viewhubmodels / routes / datamanagement.js View on Github external
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));
}
github Autodesk-Forge / forge-upgradefiles-revit / routes / common / datamanagementImp.js View on Github external
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));
}
github Autodesk-Forge / bim360appstore-model.derivative-nodejs-xls.exporter / server / data.management.tree.js View on Github external
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);
github Autodesk-Forge / forge-rcdb.nodejs / src / server / api / services / DMSvc.js View on Github external
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()
  }
github Autodesk-Forge / bim360appstore-viewer-nodejs-visual.reports / server / data.management.tree.js View on Github external
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
              ));