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 = { }; 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) { }, progress: function(p) { }, cancel: function() { }, error: function(e) { } }
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)