OneDrive Filepicker SDK può essere utilizzato per ottenere i File da OneDrive che si potrebbe utilizzare per mostrare come collegamento condivisibile o scaricare file.
Qui sono i passi per l’Installazione di OneDrive FilePicker
Passo 1:
Registro applicazione https://apps.dev.microsoft.com/ Utilizzare un URL di reindirizzamento della pagina del tuo sito web (è necessario aggiungere OneDrive.js in quella pagina). Dopo la registrazione App sarà possibile ottenere un id applicazione.
Passo 2:
Utilizzare OneDrive selezione come segue:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
<script type="text/javascript" src="https://js.live.net/v7.2/OneDrive.js" async="async"></script> <script type="text/javascript"> launchOneDrivePicker = function(that) { var odOptions = { clientId: "YOUR_APPLICATION_ID", action: "query", multiSelect: false, advanced: { redirectUri: "https://yourCommonRedirectUri.com", }, openInNewWindow: true, success: function(response) { $.each(response.value, function(index, value) { var url = response.apiEndpoint + 'drives/' + value.parentReference.driveId + '/items/' + value.id; $.ajax({ 'url': url, beforeSend: function(request) { request.setRequestHeader("Authorization", 'Bearer ' + response.accessToken); }, success: function(result) { // console.log(result); var resultData = { 'url': result['@microsoft.graph.downloadUrl'], // this returns shareable url of file 'name': result['name'], // this returns file name }; }, error: function(xhr) { }, }); }); }, cancel: function() { // called when user cancels popup action }, error: function(e) { // called when error in connecting to OneDrive api } }; OneDrive.open(odOptions); //launches file picker }; </script> |
Nota:
È possibile utilizzare un singolo URL di reindirizzamento, invece di più quando si utilizza il file picker in molte pagine web. Definire le opzioni avanzate come:
1 2 3 |
advanced: { redirectUri: "https://yourCommonRedirectUri.com", }, |
Qui è la documentazione Ufficiale e link utili per OneDrive Selezione File: