How to use the @esri/arcgis-rest-portal.createItemInFolder function in @esri/arcgis-rest-portal

To help you get started, we’ve selected a few @esri/arcgis-rest-portal 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 Esri / solution.js / packages / common / src / restHelpers.ts View on Github external
return new Promise((resolve, reject) => {
    // Create item
    const createOptions: portal.ICreateItemOptions = {
      item: {
        ...itemInfo
      },
      folderId,
      authentication: authentication
    };
    if (itemThumbnailUrl) {
      createOptions.item.thumbnailurl = itemThumbnailUrl;
    }

    portal.createItemInFolder(createOptions).then(
      createResponse => {
        if (createResponse.success) {
          let accessDef: Promise;

          // Set access if it is not AGOL default
          // Set the access manually since the access value in createItem appears to be ignored
          // Need to run serially; will not work reliably if done in parallel with adding the data section
          if (access !== "private") {
            const accessOptions: portal.ISetAccessOptions = {
              id: createResponse.id,
              access: access === "public" ? "public" : "org", // need to use constants rather than string
              authentication: authentication
            };
            accessDef = portal.setItemAccess(accessOptions);
          } else {
            accessDef = Promise.resolve({