Onedrive-api-docs: File Picker - Specify Root Folder?

Created on 22 May 2018  路  10Comments  路  Source: OneDrive/onedrive-api-docs

I'm working with the latest (7.2) version of the picker and am able to open a popup to the correct library using the following code:

window.OneDrive.open({
  clientId,
  action: 'query',
  advanced: {
    accessToken: user.access_token,
    endpointHint: drive.webUrl,
    navigation: {
      disable: true,
    },
  },
  success: files => {
    console.log(files)
  },
  cancel: () => {},
  error: err => {},
})

This is good, but what I would now like to add is a way to specify in the options a folder name or id that should function as the root folder (and not allow them to navigate above it).

I thought this might be possible due to this example code on the documentation site:

var odOptions = {
  clientId: "INSERT-APP-ID-HERE",
  action: "download",
  advanced: {
    navigation: {
      entryLocation: {
        sharePoint: {
          sitePath: "THE-SITE-PATH",
          listPath: "THE-LIST-PATH",
          itemPath: "THE-ITEM-PATH"
        }
      },
      sourceTypes: "Sites" /* or an array like ["OneDrive", "Sites"] */
    }
  },
  success: function(files) { /* success handler */ },
  cancel: function() { /* cancel handler */ },
  error: function(e) { /* error handler */ }

But there is no example of how to use itemPath. What is the correct usage of those options? And if I am confused, is there some other way to specify a root folder?

Thanks.

Needs Picker

Most helpful comment

With Graph API, I can get Sharepoint Ids, with requests like:
/groups/1c68e6bb-20bf-4b94-9d13-14379993801e/drive/root?select=sharepointIds
The result is:
listId: "8943d039-cbea-4873-8c7b-e92f34487386"
listItemUniqueId: "cc7b91b3-b9f1-4c00-86e2-1b5128362b63"
siteId: "1732760a-ac4a-40a0-b1cc-d3777acbb659"
siteUrl: "https://msdarwino.sharepoint.com/sites/team0"
webId: "da3ef5ea-1699-450e-9e5d-59beaa12acac"

How can I use this result to fill sitePath, listPah and itemPath?
I just want to open the picker for this team/group.
The user is already authenticated in the web-app (auth end point: https://login.microsoftonline.com/common/oauth2/v2.0/authorize).

All 10 comments

@brownbl1 - Have you found an answer to how to use the
sitePath: "THE-SITE-PATH",
listPath: "THE-LIST-PATH",
itemPath: "THE-ITEM-PATH"
?

@brownbl1 - Have you found an answer to how to use the
sitePath: "THE-SITE-PATH",
listPath: "THE-LIST-PATH",
itemPath: "THE-ITEM-PATH"
?

The above options refer to the path segments of the URL of the SharePoint document library which you are trying to open the picker to.

This is good, but what I would now like to add is a way to specify in the options a folder name or id that should function as the root folder (and not allow them to navigate above it).

You may also provide the disable boolean attribute as part of the navigation object mentioned here:

https://docs.microsoft.com/en-us/onedrive/developer/controls/file-pickers/js-v72/open-file?view=odsp-graph-online#customize-capabilities

Can you try the above?

This issue has been automatically marked as stale because it has marked as requiring author feedback but has not had any activity for 10 days. It will be closed if no further activity occurs within 10 days of this comment. Thank you for your contributions to OneDrive API Docs!

Could you provide an example?
I am not able to find values to set for sitePath, listPath, itemPath.
My goal is to open the picker for a specific team (or group) drive, and not the user drive.
Remark: I am working with Microsoft graph API.

With Graph API, I can get Sharepoint Ids, with requests like:
/groups/1c68e6bb-20bf-4b94-9d13-14379993801e/drive/root?select=sharepointIds
The result is:
listId: "8943d039-cbea-4873-8c7b-e92f34487386"
listItemUniqueId: "cc7b91b3-b9f1-4c00-86e2-1b5128362b63"
siteId: "1732760a-ac4a-40a0-b1cc-d3777acbb659"
siteUrl: "https://msdarwino.sharepoint.com/sites/team0"
webId: "da3ef5ea-1699-450e-9e5d-59beaa12acac"

How can I use this result to fill sitePath, listPah and itemPath?
I just want to open the picker for this team/group.
The user is already authenticated in the web-app (auth end point: https://login.microsoftonline.com/common/oauth2/v2.0/authorize).

I would also be interested in the specifications for sitePath, listPah and itemPath.

I would also be interested in sitePath, listPath and itemPath! Anything yet?

I am also trying to open a file picker to a specified SharePoint drive using sitePath, listPath, and itemPath. I have tried various permutations of the site URL, name, and drive name for these values but the picker always opens to my personal drive. How can I use the entryLocation to open the drive to a site library instead?

Hi everyone,

Onedrive filepicker was not working properly due to lack of one url parameter. Please take a look to my commit, with this small change it is working for me.

https://github.com/destinomultimedia/onedrive-javascript-filepicker/commit/2809be40b0afe8d832198f4609ce3f30dc8fdc8c

and this little small change:

https://github.com/destinomultimedia/onedrive-javascript-filepicker/commit/9032bac5afefac3d5163afa4695e637d08a6f513

:)

Hi.

So, is it still not solved? There are a few opened issues and no responses for almost a year! Anyone has found how to use JS file picker with SharePoint sites, guys?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Sanjeev143 picture Sanjeev143  路  9Comments

johnlilis picture johnlilis  路  3Comments

dluces picture dluces  路  3Comments

rkulow picture rkulow  路  7Comments

Tekki picture Tekki  路  5Comments