Directing OneDrive to the device via JavaScript / web application

Is it possible, from a website, to direct OneDrive to a user device (iPad) to capture a photo and save it in a specific folder? Can I direct OneDrive to a user device to create a folder in the same way?

In the main case, we want the web application to control the workflow, but outsource the capture of photos and asynchronously upload photos to OneDrive. But we know where the photos are and what they called, so we can upload them to our server later, when they have finished uploading and are available in the cloud.

+7
javascript ios mobile onedrive
source share
1 answer

To access the mobile camera from a mobile device, you can use the input tag as follows:

<input type="file" accept="image/*" capture="camera"> 

Now, to download the file, you can use the OneDrive JS SDK as follows:

 <script type="text/javascript" src="https://js.live.net/v7.2/OneDrive.js"></script> <script type="text/javascript"> function launchSaveToOneDrive() { var odOptions = { /* ... specify the desired options ... */ }; OneDrive.save(odOptions); } </script> <input type="file" id="fileUploadControl" name="fileUploadControl" accept="image/*" capture="camera"> <button onclick="launchSaveToOneDrive">Save to OneDrive</button> 

where odOptions will look like this:

 var odOptions = { clientId: "INSERT-APP-ID-HERE", action: "save", sourceInputElementId: "fileUploadControl", sourceUri: "", fileName: "file.txt", openInNewWindow: true, advanced: {}, success: function(files) { /* success handler */ }, progress: function(p) { /* progress handler */ }, cancel: function() { /* cancel handler */ }, error: function(e) { /* error handler */ } } 

In your success, the URL of the downloaded OneDrive file will be displayed, which will be passed for a successful callback as a parameter.

 { "value": [ { "id": "123456", "name": "document1.docx", "size": 12340, "@content.downloadUrl": "https://contoso-my.sharepoint.com/download.aspx?guid=1231231231a", "webUrl": "https://cotoso-my.sharepoint.com/personal/user_contoso_com/documents/document1.docx", "thumbnails": [ { "id": "0", "small": { "url": "https://sn3302files.onedrive.live.com/..." }, "medium": { "url": "https://sn3302files.onedrive.live.com/..." }, "large": { "url": "https://sn3302files.onedrive.live.com/..." } } ] } ] } 

See https://docs.microsoft.com/en-us/onedrive/developer/controls/file-pickers/js-v72/save-file for more details)

0
source share

All Articles