-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathIndex.cshtml
More file actions
54 lines (50 loc) · 1.68 KB
/
Index.cshtml
File metadata and controls
54 lines (50 loc) · 1.68 KB
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
44
45
46
47
48
49
50
51
52
53
54
@{
ViewData["Title"] = "Home Page";
}
<script type="text/javascript">
function launchOneDrivePicker() {
$("#selectedThumbnailImg").attr("src", "");
var odOptions = {
clientId: "ENTER_YOUR_APP_ID",
action: "query",
multiSelect: false,
advanced: {
filter: ".png,.jpg,.jpeg",
queryParameters: "select=id"
},
success: function (response) {
if (response && response.value.length > 0) {
$.ajax({
type: 'POST',
url: '@Url.Action("Index", "Home")',
data: {
AccessToken: response.accessToken,
FileId: response.value[0].id,
DriveId: response.value[0].parentReference.driveId
},
success: function (result) {
$("#selectedThumbnailImg").attr("src", result);
console.log('Data received: ');
console.log(result);
}
});
}
},
cancel: function () { alert('Operation cancelled'); },
error: function (e) { alert('An error occourred: ' + e); }
}
OneDrive.open(odOptions);
}
</script>
<div class="row">
<div class="col-md-3">
<h2>ASP.NET File Picker</h2>
<button onClick="launchOneDrivePicker()">Open from OneDrive</button>
</div>
</div>
<br/>
<div class="row">
<div class="col-md-3">
<img id="selectedThumbnailImg" />
</div>
</div>