Name: onedrive-file-picker
Owner: Nuxeo
Description: JavaScript file picker for OneDrive & OneDrive for Business
Created: 2016-02-18 14:41:10.0
Updated: 2016-09-07 03:09:51.0
Pushed: 2016-08-24 14:55:22.0
Homepage: null
Size: 105
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
The OneDrive & OneDrive for Business file picker is a light JavaScript picker over the OneDrive REST API. It is designed to work with both OneDrive & OneDrive for Business and to have light dependencies. Check your live demo.
Download the latest release here or build it from master.
You also need jQuery in your page. The file picker was built with jQuery 1.8.0, it should work with lower version.
Then include jQuery and file picker scripts in your page :
ipt type="text/javascript" src="https://code.jquery.com/jquery-1.8.0.min.js"></script>
ipt type="text/javascript" src="onedrive-file-picker.js"></script>
k rel="stylesheet" type="text/css" href="onedrive-file-picker.css">
You can follow the OneDrive documentation page to obtain an access token. This part has to be done by your application, as the file picker needs an access token to work.
For OneDrive just init the file picker with access token :
accessToken = '...';
picker = new OneDriveFilePicker({ 'accessToken': accessToken });
For OneDrive for Business, the file picker needs an access token and the resource url to access the api.
accessToken = '...';
baseURL = 'https://{tenant}-my.sharepoint.com/_api/v2.0'; // For example : https://nuxeo-my.sharepoint.com/_api/v2.0
picker = new OneDriveFilePicker({ 'accessToken': accessToken, 'baseURL': baseURL });
Once you have your file picker instance, you can call select
method to open it. The method return a Promise
, if you're not familiar with it, see this page. Once user has selected a file or closed the picker, the Promise
will be resolved.
er.select().then(function(result) {
Your code here
You get an object with at least action
attribute which could be :
item
attribute which contains the selected item metadata.You can also catch error thrown from API, like unauthorized errors, with catch Promise method :
er.select().catch(function(error) {
Your code here
The API error contains the textual portion of the HTTP status, such as “Not Found” or “Internal Server Error.”
See our contribution documentation.
Install Node.js and then use npm
to install all the required libraries:
t clone https://github.com/nuxeo/onedrive-file-picker
onedrive-file-picker
m install
You can run a live demo during development with hot reload, just enter in your terminal :
lp demo
Nuxeo dramatically improves how content-based applications are built, managed and deployed, making customers more agile, innovative and successful. Nuxeo provides a next generation, enterprise ready platform for building traditional and cutting-edge content oriented applications. Combining a powerful application development environment with SaaS-based tools and a modular architecture, the Nuxeo Platform and Products provide clear business value to some of the most recognizable brands including Verizon, Electronic Arts, Sharp, FICO, the U.S. Navy, and Boeing. Nuxeo is headquartered in New York and Paris. More information is available at www.nuxeo.com.